please help me to answers this question about C++.....huuhuhuhu

please help me to answers this question about C++.....huuhuhuhu

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

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.... Please enter character"); else { ch = brr.charAt(0...("It is not character. Please enter character"); else { ch
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
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
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
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
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
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
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.  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...
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 in these prog
please help me in these prog   create 2 jdbc programs including awt create 2 jdbc programs including swing create 2 jdbc programs including command line argument create 2 jdbc programs including io class 4 jdbc prog using
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 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
Help me please!!! - Java Beginners
Help me please!!!  im badly needing the complete code for this project in java!!! can you please help me???!!! it is about 1-dimensional array... the answers 8Hours from now!!! Kindly help me!! please!!please!!! NOTE
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,ADS_TO_REPLACE_1 If you want
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
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??  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
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  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
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
please help me here
please help me here  please show me how can this show the right output that i need please continue doing this program using only if else and do while please please" here is the problem Automatic Teller Machine [B] Balance [D
please help me here
please help me here  please show me how can this show the right output that i need please continue doing this program using only if else and do while please please" here is the problem Automatic Teller Machine [B] Balance [D
Please help me to learn - WebSevices
Please help me to learn  Please help me to learn Java Fast
please help me to overcome this problem
please help me to overcome this problem  how to make it easy to write java code. can u please give me suggestions
help me to solve this question...
help me to solve this question...  Given below is a class definition for Book. Type and compile the class, and answer the following questions: class Book { String title; //bookâ??s title double price; //bookâ??s
pls help me with this question
pls help me with this question  how to write a program in C++ using encapsulation,polymorphism,inheritance and abstraction?(all these concepts should come in a single program
help me to solve this question
help me to solve this question  Write a program that inputs a series of integers into an array. The numbers are in the range 0 to 100. Calculate and display : a) The Largest number b) The Smallest Number c)The sum of the numbers
HQL Statement: Please help me
= Product.productGroupVersionId and Product.lobId = ? Can you please help me equallent HQL...HQL Statement: Please help me  Select ProductFamily.* from ProductFamily, ProductGroup, Product where ProductFamily.productFamilyVersionId
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
plz help me for this question
plz help me for this question  Apply simplex procedure to solve the L.P.P. maximize z = 3x1 + 4x2 subject to 5x1 + 4x2 â?¤ 200; 3x1 + 5x2 â?¤ 150; 5x1 + 4x2 â?¥ 100; 8x1 + 4x2 â?­â?¥ 80, x1 â?¥ 0, x2 â?¥ 0
help me to solve this question
help me to solve this question   A user needs to key in data into system in order to save data into array. The data are: a. Lecturer ID, Lecturer... 2010/2011 2 c. Session and semester ââ?¬â?? The system
Please help me understand this query
Please help me understand this query  Hi, Could someone please help me understand the following query. Im finding difficulty relating it :-( Pls Help! select * from cbpartner where CBPartner.IsSummary='N' and salesrep_id
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
Begineer in coding please help me
address to a person object.. please help me...Begineer in coding please help me  I have Person class{ int pid; String Pname; //and have a Address filed of type Address not String!!! Address
would you please help me?
would you please help me?  Write a class Amount which stores sums of money given in pounds and pence. Your con- structor should take two ints, for pounds and pence seperately. The class should also provide methods to add
please help me - Java Beginners
please help me   I have some error in this programe //write acomputer programe using java to generate following series : //output: //1,2,3,0,-2,7,-4..... class Series1HW { public static void main(String args
please give me an idea to develop a program for this question?
please give me an idea to develop a program for this question?  How to enter a text or number from keyboard without using InputStreamReader method in java
Please help me... its very urgent
Please help me... its very urgent  Please send me a java code to check whether INNODB is installed in mysql... If it is there, then we need to calculate the number of disks used by mysql

Ads