0 calificaciones0% encontró este documento útil (0 votos)
64 vistas5 páginas
The document contains a quiz with multiple choice questions about various computer science concepts like data structures, algorithms, trees, graphs, classes, pointers, and more. The questions cover topics like time complexity of algorithms, disadvantages of sequential storage, implementing linked lists, stack operations, recursion, sorting algorithms, tree traversals, expressions in postfix notation, relationships in graphs, and differences between classes and structures in C++.
The document contains a quiz with multiple choice questions about various computer science concepts like data structures, algorithms, trees, graphs, classes, pointers, and more. The questions cover topics like time complexity of algorithms, disadvantages of sequential storage, implementing linked lists, stack operations, recursion, sorting algorithms, tree traversals, expressions in postfix notation, relationships in graphs, and differences between classes and structures in C++.
The document contains a quiz with multiple choice questions about various computer science concepts like data structures, algorithms, trees, graphs, classes, pointers, and more. The questions cover topics like time complexity of algorithms, disadvantages of sequential storage, implementing linked lists, stack operations, recursion, sorting algorithms, tree traversals, expressions in postfix notation, relationships in graphs, and differences between classes and structures in C++.
Computer hardware Data structures Algorithms All of the above 2 Data object integers is {1,2,,!!!!!!!" {#,1,2, !!!!!!!!" {!!!!!$,$2,$1,#,1,2,!!!!!!!!" %one of the above &he 'ig ( times for traversal of binary tree with any method is ()1* ()log n* ()n log n* ()n* + &he disadvantages of se,uential storage allocation is -npredictable storage re,uirement %eed of an inde. /.tensive manipulation of data stored %one of the above 0 1ow many objects of the lin2ed list class are normally used to implement a lin2ed list 3 (ne /,uals number of nodes %one %one of the above 4 5n the C66 code that pushes an item onto stac2, should you insert the item first or increment the top first! )when top is initiali7ed to $ 1 5ncrement first then push %o need to increment the top %one of the above 8 9hy is wrap around necessary for ,ueues but not for stac2s 3 :ueues grow from one end and shrin2 from the other and Stac2s grow and shrin2 from same end Stac2s grow from one end and shrin2 from the other and :ueues grow and shrin2 from same end %one of the above ; 9hy is recursion used 3 'ecause it is more efficient <esser function overheads Simplifies problem conceptually <oop approach does not wor2 in all situations = 9hat does it mean to partition a number of data items in :uic2 sort %umbers are divided in two e,ual halves &o put those with a 2ey greater than 7ero in one group, and those with 2ey less than 7ero in the group &o put those with a 2ey greater than certain 2ey in one group and those with certain 2ey less than 7ero in another group %one of the above 1# 9hat three tas2s should a recursive function e.ecute to perform an in order traversal 3 >isit the node, Call itself to traverse a nodes left sub tree, and call itself to traverse the nodes right sub tree! Call it to traverse a nodes left subtree, visit the node, and call it to traverse the nodes right sub tree! >isit the node, Call it to traverse a nodes right sub tree, and call it to traverse the nodes left sub tree! Call itself to traverse a nodes right sub tree, visit the node, and call itself to traverse the nodes left sub tree! 11 5n a tree with % nodes, how many nodes must be e.amined to find a given node 3 % nodes <og2% nodes % log2% nodes 1 node 12 1ere is an e.pression in postfi. notation? A'6C$! /.press this in infi. notation! A ' C 6 $ 6 $ A ' C A 6 ' $ C A ' 6 $ C 1 A graph represents a -nidirectional relationship 'i$directional relationship 'oth unidirectional and bi$directional relationship %one of the above 1+ &he main logic of Depth first traversal of a graph is analogous to @reorder traversal @ostorder traversal 5norder traversal %one of the above 10 9hen the class member functions are defined inside the class body, by default they may be considered as inline functions! &rue Aalse 14 Ariendship is transitive i!e! if A is a friend function of ' and ' is a friend of C, then C is friend of A! &rue Aalse 18 BthisB pointer is passed to the non member functions also! &rue Aalse 1; Choose the correct option?$ Abstraction of an object is defined as 1iding unnecessary attributes of an object! @rocess of 2nowing essential attributes of an object! @rocess of 2nowing attributes of an object! All of above! 1= const 2eyword is used for those objects? 9hich canBt be instantiated 9hich canBt be modified 9hich need not be initiali7ed %one of the above 2# 9hat is the difference between struct and class in C66 3 Default scope of struct is public and class is private! struct do not have functions as their data members and class do have! a and b are true! %one of above! 21 new and malloc differs by malloc can not be used in C66! malloc does not call constructor when creating object on heap, while new calls constructor malloc is function and new is an operator! 'oth b and c! 22 5n C66, static functions in class Can be invo2ed only after instantiating an object of the class! Contains CthisD pointer implicitly! Can access only static data members! Can access both static data and non$static data members! 2 &he conversion operator functions should be A class member Eust not specify return type Eust not have any arguments All the above 2+ Assume the class String)having the data members character pointer str and integer length* StringFString??operatorG)const StringF s* { deleteHI strJ str G new charHs!length61IJ strcpy)str,s!str*J length G strlen)str*J return)Kthis*J " &he above overloaded operator G function for class String will not wor2 for which of the following assignment statements String a)LhelloL*, b)LhiL*J a G bJ String a)LhelloL*, FbGaJ a G bJ String a)LhelloL* ,b)LhelloL*J a G bJ All of the above 20 9hich concept is represented by the sample code below ? class Sample { private? int num,denoJ public? Sample)int n,int d* { numGnJdenoGdJ " operator float)* { return))float*numMdeno*J " "J void main)* { Sample s1)8,*J float resultJ result G )float*s1J coutNNresultJ " (perator overloading 5mplicit typecasting Code is not valid in C66 Conversion operator 24 9hat will be the output3 void f)int F.1,int Ky1,int 71* { .1 G .16Ky1J Ky1 G 71J 71 G +#J " void main )* { int .G1#,yG2#,7G#J f )., Fy, 7*J cout NN . NN y NN 7 NN endlJ " 1#, 2#, # #, #, # #, 2#, +# #, #, +# 28 class A { static int .J public? $$$$$$$$$$ $$$$$$$$$$ "J int A??.J void main)* { A obJ coutNNob!.J " Cannot have a static data member in a class # -ndefined)garbage* Compilation error 2; &he constructor and destructor functions never get inherited! &rue Aalse 2= &here is only one virtual table per class! &rue Aalse # containment is? Cis a 2indD of relationship C is a part Cof relationship both a F b are true both a F b are false 1 5n C66, Dynamic binding is used for all methods! Dynamic binding is used for public methods only! Dynamic binding is used for virtual methods only! Static binding is used for all methods! 2 Class m? public n,virtual public o {"J 9hat is the order for constructor call if object of class m is created3 A! Constrtctor of m '! Constrtctor of n C! Constrtctor of o A, ', C C, ', A C, A, ' A, C, ' 5n the diamond inheritance,the data duplication is avoided by ma2ing the base class OOOOOOOOOO! >irtual @ure >irtual Ariend %one of the above + 5f members of namespace are accessed outside the namespace, then its scope must be resolved with the namespace name and scope resolution operator! &rue Aalse 0 &emplate functions can not be overridden! &rue Aalse 4 &he e.ception handling mechanism is supposed to handle compile time errors! &rue Aalse 8 &emplates can be for? Classes Auntions 'oth %one ; 5f a catch statement is written to catch e.ception objects of a base class type, it can also catch all OOOOOOOOO derived from that base class! /.ceptions of objects Arguments /rrors %one of the above = 9hen objects are stored into a file Data members along with public member functions of the objects are copied! (nly data members are copied! (nly public member functions are copied! %one of above! +# void main)* { istream finJ char buffH2#IJ fin!getline) buff, 2#, B!B*J " Arom the above code how many characters will be read from the given input file till All 2# characters! &ill user enters the new line character! &ill user enters the full stop character! &ill user enters the space bar! +1 /very function in C66 is name mangled! &rue Aalse +2 A constructor can be used to convert a basic type to a class type data! &rue Aalse + A OOOOOOOOOO is a type of random access array that provides fast random access to array elements as well as fast insertion and deletion! map multimap list vector ++ class yourself { int intelligenceJ public? yourself)int great*{intelligenceGgreatJ" yourself)yourself F y* {intelligenceGy!intelligence" "J void main)* { yourself yourghost)1*J yourself you)yourghost*J " Peferring to the sample code above,what initialises the object you ! Copy constructor! Default constructor! Single parameterised constructor! %one of the above! +0 A member function that can be invo2ed by class name is Static inline friend virtual +4 5dentify which of the following function calls are allowed given the prototype declaration int sum)int a,int bG1Jint cG#*J 1* coutNNsum)1*J 2* coutNNsum)1,2*J * coutNNsum)*J +* coutNNsum)2,2,*J 1,2 and + 2, and + 1 and + 2 and + +8 comple.{ int i,rJ public? static void display)*{coutNNthis$QiNNthis$QrJ" comple.)int a,int b*{iGaJrGbJ" " void main)*{ comple. c1)1#,2#*J c1!display)*J " 1# 2# # # garbage %one of the above +; Abstract class cannot be instansiated but references and pointers of the abstract class e.ists! &rue Aalse += 5nput iterators are used only to read from a se,uence! &rue Aalse 0# class person { public? person)*J virtual Rperson)*J "J class student?public person {public? student)*J Rstudent)*J "J void main)* { person K ptr G new studentJ " Peferring to the sample code above why is the 2eyword LvirtualL added before the person destructor3 &o ma2e person abstract base class ! Aor inheritance atleast one function must be virtual! &o ma2e it possible for this particular destructor to be overloaded &o ensure the proper destruction of the derived object! 01 class Animal { "J class Eammal ? public virtual Animal { "J class Amphibian ? virtual public Animal { "J class @latypus ? public Eammal, public Amphibian { Animal aJ "J 9hat, if anything, is wrong with the sample code above3 Animal is not an abstract base class and so cannot be virtually inherited in Eammal! A multiple derived class cannot have an instance of a base class object )Animal in @latypus*! &he 2eyword virtual in misplaced! 5t needs to come before the access specifier! %othing! 02 9hich data structure grow or shrin2 during run time 3 Stac2 :ueue &ree Array 0 9hich of the following is the feature of stac2 3 All operations are at one position 5t cannot reuse its memory All elements are of different types Any element can be accessed from it 0+ %ew $Q data G 2# J %ew $Q ne.t G temp $Q ne.t J temp $Q ne.t G new J &his will OOOOOOOO the item )%ew* in the singly lin2listlist insert modify delete traverse 00 first $Q ne.t G first J first $Q prev G firstJ &his notation is used in OOOOOOOOOO Circular lin2 list Singly lin2 list Doubly Circular <in2 <ist <in2ed Stac2 04 9hich of the following is not true in regarding the singly lin2ed list 3 %odes are lin2ed in one direction Address of the list is the address of last node &he last node is pointing to %-<< indicate the end of the list Searching for a node always starts at the first node and traverses through every subse,uent bodes 08 &he set container does not permit duplicate values! &rue Aalse 0; At what point would you say a program is prevented from adding nodes to a <in2ed <ist3 9hen all the nodes have been used! 9hen the computer runs out of memory 9hen the <in2ed <ist is <onger than Specified %ever 0= 9hich is most powerful iterator 5nput iterator (utput iterator Pandom access iterator bidirectional iterator 4# the BfindB algorithm ta2es the parameters in the following order! iterator to end of the container, iterator to start of the container, value to be searched value to be searched, iterator to end of the container, iterator to start of the container iterator to start of the container, iterator to end of the container, value to be searched iterator to the start of the container, value to be searched