Quiz 4
thanks for your helpCode: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.



LinkBack URL
About LinkBacks


