Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa HTML please help me to answers this question about C++.....huuhuhuhu
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


syaminismail
please help me to answers this question about C++.....huuhuhuhu
2 Answer(s)      3 years and 3 months ago
Posted in : HTML


1) Write a full program for the bubble sort algorithm. User is required to enter specific input numbers and the program will be able to sort the given numbers in ascending order. Write down in a table the time (according to your system clock) that it takes for the program to complete. You may do this by running the program for several values of input.

Hints: a) Write full source code b) Use system clock to measure the running time c) Use several input (eg: N = 100 , N = 1000 , N = 10000, N = 100000 etc) d) Have access to a file (to store your running time)

2) What is the difference between static and dynamic memory allocations? List advantages and disadvantages for the both type of memory allocations.

3) Use structure to wrap student information (such as Matrix Number, name and MTS 3023 mark) and manipulate it by reading information to an array of student structure and print them on to console screen.

4) The common error message which might encounter in your program is ?memory access violation? or ?segmentation violation?. What does it mean? How to avoid it?

5) For each of the following four program fragments: a. Give an analysis of the running time (Big-Oh) b. Implement the code and give the running time for several values of N c. Compare your analysis with the actual running times


Advertisement
View Answers

October 4, 2011 at 12:05 PM


C++ Bubble Sort

#include <iostream>
using namespace std;

void sort(int ar[], int size)
{
    int temp;
    for(int i = 0; i < size; i++)
        for(int j = 0; j < size - i - 1; j++)
            if(ar[j] > ar[j + 1])
            {
                temp = ar[j];
                ar[j] = ar[j + 1];
                ar[j + 1] = temp;
            }
}

int main()
{
    int *array;
    int size;
    cout << "Enter size of array: ";
    cin >> size;
    array = new int[size];
    for (int x = 0; x < size; x++)
    {
        cout << "Enter value for index " << x + 1 << ": ";
        cin >> array[x];
    }
    cout << "Before sorting: ";
    for (int i = 0; i < size; i++)
    {
        if (i == (size - 1))
            cout << array[i];
        else
            cout << array[i] << ", ";
    }
    sort(array, size);
    cout << "\nAfter sorting: ";
    for (int j = 0; j < size; j++)
    {
        if (j == (size - 1))
            cout << array[j];
        else
            cout << array[j] << ", ";
    }
    cin.ignore();
    cin.get();
    delete array;
    return 0;
}


October 4, 2011 at 12:24 PM


Difference between Static and Dynamic Memory Allocation:

1)Dynamic memory allocation is at runtime. static memory allocation is before run time, but the values of variables may be changed at run time. Static memory allocation saves running time, but can't be possible in all cases.

2)Dynamic memory allocation stores it's memory on heap, and the static memory allocation stores it's data in the "data segment" of the memory.



Related Tutorials/Questions & Answers:
please help me to answers this question about C++.....huuhuhuhu
please help me to answers this question about C++.....huuhuhuhu  1... clock to measure the running time c) Use several input (eg: N = 100 , N = 1000.... Implement the code and give the running time for several values of N c. Compare your
please help me to answers this question about C++.....huuhuhuhu
please help me to answers this question about C++.....huuhuhuhu  1... clock to measure the running time c) Use several input (eg: N = 100 , N = 1000.... Implement the code and give the running time for several values of N c. Compare your
Advertisements
please help me to solve this question about array
please help me to solve this question about array  write a program...() > 1) System.out.println("It is not character. Please enter...(); if (brr.length() > 1) System.out.println("It is not character. Please
Please help me about maven2 plugin - Maven
Please help me about maven2 plugin  First, thanks you for your all tutorial. That are the best tutorial i've learned. Then, I want to ask you about... an error. I send you the image i capture the error Please help me
please any one can help me to write a code for this question?
please any one can help me to write a code for this question?  1) Copy one file content to other? 2) Count the number of words in a file
please any one can help me to write a code for this question?
please any one can help me to write a code for this question?  Q 1) In a class first day 25 students are joined. After two days that total students will increased to 60. We can develop a program by using ArrayList concept
please help me.
please help me.  How to move the edits.jsp in below link? http://www.roseindia.net/answers/viewqa/JSP-Servlet/9584-JSP-Servlet-Search-and-Edit.html
please help me.
please help me.  Please send me the validation of this below link. the link is http://www.roseindia.net/answers/viewqa/JSP-Servlet/9584-JSP-Servlet-Search-and-Edit.html Thanks Trinath
Please help me.
Please help me.  Hi i am trinath in below there is a url.In that url there is a code of edit a jsp page.I understand that code but only one thing i...://www.roseindia.net/answers/viewqa/JSP-Servlet/9584-JSP-Servlet-Search
I really need help with this assignment question Please help me out Please
I really need help with this assignment question Please help me out Please  * Description* You are hired to develop a laptop inventory information system for Sheridan College in order to keep track of the information about
help me please
help me please   Hello I want helping for this question , Please Write a program that reads some friendsââ?¬â?¢ names, stores them in an array, and then prints out on the screen all friends who start by a particular letter
problem question please need urgent answers
problem question please need urgent answers  Problem Statement Given a cyclic list with elements as numbers in sorted order, write a function to insert a new element (5) into the cyclic list that maintains the sorted order
problem question please need urgent answers
problem question please need urgent answers  Problem Statement Given a cyclic list with elements as numbers in sorted order, write a function to insert a new element (5) into the cyclic list that maintains the sorted order
please help me.
please help me.  I have three table in mysql,and i hava create a excel sheet and add this sheet.but my question is in every sheet i can display one one table result.how can i do
urgent...pleAse help me.....please!
urgent...pleAse help me.....please!  please help me urgent! how can i do dictionary with the use of array code in java, where i will type the word then the corresponding meaning for that word will appear...thanks
please help me.
please help me.  Please send me a code of template in opencms and its procedure.so i can implement the code. Thanks trinath
please help me.
please help me.  How to read a properties file in java with a suitable example. Please send me. Thanks Trinath   Please visit the following link: Java read properties file
plz Help me find the correct programs answers
plz Help me find the correct programs answers   Create a washing machine class with methods as switchOn, acceptClothes, acceptDetergent, switchOff... INDICA" and "TATA NANO" respectively. Plz mail me your answers
please help me.
please help me.  I have a jsp page under that i add a list box under i get the countries through my database. so how can i do
please help me
before. This name list should get from the database. Please help me. By the way, I'm...please help me  Dear sir, I have a problem. How to write JSP coding, if a user select a value from drop down list for example department, the another
Please help me out
Please help me out    Description* You are hired to develop a laptop inventory information system for Sheridan College in order to keep track of the information about the laptops lent to the students. Users can add or remove data
please help me...
please help me...  write an application that print number in the following order using a FOR-Loop 1 2 3 4 5 2 4 6 8 10 3 6 9 1215 4 8 121620 5 10152025
please help me to this problem..
please help me to this problem..  i wrote a program like keyboard... inside the JTextField) but i want to make this program to let me write where i clicked (i.e allows me to write any thing at the field where i clicked
Please help me urgent...........
Please help me urgent...........  For what kind of a problem would use a Tree Set and not a Tree Map For what kind of a problem would use a Tree Map and not a Tree Set   Hello Friend, If you want to display the list
Please help me
Please help me  program for when a user enter his card number, it has to create default security pin in the database
Please help me
Please help me  Hi Sir, please send me the code for the following progrems... 1) all sets are integer type: input: set1={10,20,30,40} set2={15,25,35} output: union={10,15,20,25,30,35,40} 2) input: "Hi what
please help me
please help me  interface Test1 { String toString(); } public class Test { public static void main(String[] args) { System.out.println(new Test1() { public String toString() { return "test
help me please
help me please  how can i do dictionary with the use of array code in java, where i will type the word then the corresponding meaning for that word will appear...thanks
Please help me??
Please help me??  Question_1: Using one-dimension array of primitive type elements. Objective: The purpose of this lab exercise is to practice how to declare, create and manipulate a one-dimension array of primitive type
please help me?
please help me?  Define a class named Circle with the following properties: List item An integer data field named radius with protected access modifier, and a String data field named colour with private access modifier. Both
please help me
please help me  how to use two browse buttons, one browse button for displaying the first image and second for the second image along with its file path and also to display text file along with its path using layouts or panels
Advertisements
 

 

 

DMCA.com