Quiz on Adts if you can give me the answers thanks

This is a discussion on Quiz on Adts if you can give me the answers thanks within the C Programming forums, part of the General Programming Boards category; Quiz 4 Code: 1 Marks: 1 Given the following code fragment: unsigned int* buffer = malloc(sizeof(unsigned int) * 10); unsigned ...

  1. #1
    Registered User ortegac's Avatar
    Join Date
    Mar 2006
    Location
    In front of the computer screen
    Posts
    15

    Quiz on Adts if you can give me the answers thanks

    Quiz 4
    Code:
    1
    Marks: 1
    
    Given the following code fragment:
    
    unsigned int* buffer = malloc(sizeof(unsigned int) * 10);
    unsigned int* p;
    int i;
    
    for (p = buffer, i = 0; p <= &buffer[9]; p+=2, i++)
    *p = i;
    
    Note: 
    SizeOf(unsigned int) = 2 bytes
    SizeOf(int) = 4 bytes.
    
    What are the contents of the memory area that buffer points to, after execution of the above code?
    
    Answer:  	
    	a. [0,1,0,2,0,3,0,4,0,5]	
    	b. [1,23,45,67,89,X,X,X,X,X] where X is unknown value	
    	c. The above code is invalid.	
    	d. [0,X,1,X,2,X,3,X,4,X] where X is unknown value	
    	e. [0,1,2,3,4,5,6,7,8,9]	 	
    Incorrect
    Marks for this submission: 0/1. 
    
    2
    Marks: 1
    
    Consider the following Union data structure:
    
    union{
    char* c_ptr;
    float* f_ptr;
    union {
    int* iptr_arr[2];
    float f;
    }
    }
    
    Given that 
    SizeOf(int) = 4 bytes, 
    SizeOf(float) = 4 bytes 
    SizeOf(char) = 1 byte
    SizeOf(char*) = 4 bytes
    
    What is the correct size of the data structure above?
    Answer:  	
    	a. SizeOf(float*) + SizeOf(int) X 2	
    	b. None of the above	
    	c. SizeOf(char*) X 2	
    	d. SizeOf(int*) X 2 + SizeOf(float)	 	
    	e. SizeOf(int*) + SizeOf(int) X 2	
    Incorrect
    Marks for this submission: 0/1. 
    
    3
    Marks: 1
    Which of the following operations will consume the greatest amount of time in a worst case scenario in a stack?
    Answer:  	
    	a. Both push and pop will take the same time.	
    	b. delete	
    	c. insert	
    	d. push	 	
    	e. pop	
    Incorrect
    Marks for this submission: 0/1. 
    
    4
    Marks: 1
    Which of the following operations will have the largest amount of time consumed in a linked list? (in the worst case)
    Answer:  	
    	a. insert	
    	b. delete	 	
    	c. append	
    	d. Both insert and delete	
    Incorrect
    Marks for this submission: 0/1. 
    
    5
    Marks: 1
    Push and Pop are appropriate operations for which data structure:
    Answer:  	
    	a. List	 	
    	b. Stack	
    	c. Array	
    	d. Queue	
    	e. Tree	
    Incorrect
    Marks for this submission: 0/1. 
    
    6
    Marks: 1
    What kind of list is best to answer questions such as "What is the item at position n?"
    Answer:  	
    	a. Singly-linked lists.	 	
    	b. Lists simulated with an array.	
    	c. Doubly-linked lists.	
    	d. Doubly-linked or singly-linked lists are equally best.	
    Incorrect
    Marks for this submission: 0/1. 
    
    7
    Marks: 1
    
    The use of modules and generic program modules are programming techniques designed to promote:
    Answer:  	
    	a. parallelism	
    	b. generality	
    	c. exception handling	
    	d. procedural abstraction	 	
    	e. data abstraction	
    Correct
    Marks for this submission: 1/1. 
    
    8
    Marks: 1
    The terms FIFO and LIFO would most likely arise during a discussion of:
    Answer:  	
    	a. Binary Trees	
    	b. Queue	 	
    	c. Compiler Design	
    	d. Storage Media	
    Correct
    Marks for this submission: 1/1. 
    
    9
    Marks: 1
    Which of the following operations will have the greatest amount of time consumed in a prioritized queue? (in the worst case scenario)
    Answer:  	
    	a. pop	
    	b. enque	
    	c. deque	 	
    	d. push	
    	e. both enque or deque	
    Incorrect
    Marks for this submission: 0/1. 
    
    10
    Marks: 1
    
    Suppose the following variables are declared in a C-Like Language:
    
    int X; 
    int Y; 
    int* R; // an integer pointer 
    int* S; // an integer pointer
    
    Which of the following assignments is invalid?
    
    Note: 
    
    &Var returns the address of the variable Var, 
    *Add returns the contents stored at address Add.
    
    Answer:  	
    	a. *R = X;	
    	b. R = &X;	
    	c. &X;	 = &Y;	
    	d. X = * (&Y);	
    	e. 
    R = &X;	
    Y = *R + X;	 	
    Incorrect
    Marks for this submission: 0/1.
    thanks for your help

  2. #2
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,475
    Is this homework? or somthing for fun?

  3. #3
    Registered User ortegac's Avatar
    Join Date
    Mar 2006
    Location
    In front of the computer screen
    Posts
    15

    is a quiz that i did in college

    i got them wrong for the quiz and i want to know the answer i only got 7 and 8 right.

    Plese help me out if you can

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,494
    How about you post which answers you chose, and why you thought that answer was correct.

    Given multiple choice answers of 1 out of 4 or 5, getting just 2 out of 10 right is do-able simply by chance rather than skill.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Accepting Word/Sentence Answers
    By Syllable in forum C++ Programming
    Replies: 2
    Last Post: 09-08-2006, 02:57 PM
  2. answers for Ivor Horton's Beginning C++?
    By 7stud in forum C++ Programming
    Replies: 1
    Last Post: 03-16-2005, 11:13 PM
  3. Text-based quiz game
    By MipZhaP in forum Game Programming
    Replies: 7
    Last Post: 09-09-2004, 02:33 PM
  4. Quiz
    By VirtualAce in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 06-27-2003, 09:16 AM
  5. Answers for exercise in K & R
    By kermit in forum C Programming
    Replies: 7
    Last Post: 01-25-2003, 07:38 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21