CPP and DataStructures

Description

SecondYear Second Year Quiz on CPP and DataStructures, created by Faheem Ahmed on 19/10/2017.
Faheem Ahmed
Quiz by Faheem Ahmed, updated more than 1 year ago
Faheem Ahmed
Created by Faheem Ahmed over 6 years ago
640
0

Resource summary

Question 1

Question
Two main measures for the efficiency of an algorithm are
Answer
  • Processor and memory
  • Complexity and capacity
  • Time and space
  • Data and space

Question 2

Question
The complexity of Binary search algorithm is
Answer
  • O(n)
  • O(log n)
  • O(n^2)
  • O(n log n)

Question 3

Question
Which of the following data structure is not linear data structure?
Answer
  • Arrays
  • Linked lists
  • Both
  • None

Question 4

Question
The complexity of merge sort algorithm is
Answer
  • O(n)
  • O(log n)
  • O(n^2)
  • O(n log n)

Question 5

Question
When determining the efficiency of algorithm the time factor is measured by
Answer
  • Counting microseconds
  • Counting the number of key operations
  • Counting the number of statements
  • Counting the kilobytes of algorithm

Question 6

Question
When determining the efficiency of algorithm, the space factor is measured by
Answer
  • Counting the maximum memory needed by the algorithm
  • Counting the minimum memory needed by the algorithm
  • Counting the average memory needed by the algorithm
  • Counting the maximum disk space needed by the algorithm

Question 7

Question
Which of the following is not the internal sort?
Answer
  • Insertion Sort
  • Bubble Sort
  • Merge Sort
  • Heap Sort

Question 8

Question
Given two sorted lists of size m and n respectively.The number of comparisons needed in the worst case by the merge sort algorithm will be?
Answer
  • mn
  • max(m,n)
  • min(m,n)
  • m+n-1

Question 9

Question
To represent hierarchical relationship between elements, Which data structure is suitable?
Answer
  • Tree
  • Graph
  • Queue
  • Stack

Question 10

Question
The postfix expression for * + a b - c d is?
Answer
  • ab + cd - *
  • ab cd + - *
  • ab + cd * -
  • ab + - cd *

Question 11

Question
A circular queue is implemented using an array of size 10. The array index starts with 0, front is 6, and rear is 9. The insertion of next element takes place at the array index.
Answer
  • 0
  • 7
  • 9
  • 10

Question 12

Question
Which type of traversal of binary search tree outputs the value in sorted order?
Answer
  • Pre-order
  • In-order
  • Post-order
  • None

Question 13

Question
If the given input array is sorted or nearly sorted, which of the following algorithm gives the best performance?
Answer
  • Insertion sort
  • Selection sort
  • Quick sort
  • Merge sort

Question 14

Question
The type of expression in which operator succeeds its operands is?
Answer
  • Infix Expression
  • prefix Expression
  • postfix Expression
  • None

Question 15

Question
The postfix form of the expression (A+ B)*(C*D- E)*F / G is?
Answer
  • AB+ CD*E - FG /**
  • AB + CD* E - F **G /
  • AB + CD* E - *F *G /
  • AB + CDE * - * F *G /

Question 16

Question
In linked list, pointer is pointing to the first element of the node then time require to insert element to second position is
Answer
  • O(n)
  • O(1)
  • O(n^2)
  • O(n-1)

Question 17

Question
Time require to find any element of the linked list is
Answer
  • O(n)
  • O(1)
  • None of these
  • O(n^2)

Question 18

Question
If start is pointing to first node of the linked list then consider the following statement - start = start->next; current = start->next; what will be the value of address field of current ?
Answer
  • 5571
  • 5572
  • 3225
  • 2184

Question 19

Question
Consider the following linked list and following linked list representation - struct node { int data; struct node *next; }*start = NULL; what will be the value of following statement ? start->next->next->next->data
Answer
  • 12
  • 30
  • 15
  • 25
  • 10

Question 20

Question
In Circular Linked List insertion of a node involves the modification of ____ links.
Answer
  • 1
  • 2
  • 3
  • 4

Question 21

Question
If in a linked list address of first node is 1020 then what will be the address of node at 5th position ?
Answer
  • 1036
  • 1028
  • 1025
  • None of these

Question 22

Question
Which of the following operation is performed more efficiently in doubly linked list ?
Answer
  • Inserting a node at given position
  • None of these
  • Deleting a node at given position
  • Searching a node at given position

Question 23

Question
When new element is added in the middle of singly linked list then ________.
Answer
  • Only elements that appear after the new element need to be moved
  • Only elements that appear before the new element need to be moved
  • No need to move element
  • Only elements that appear after the new element and before need to be moved

Question 24

Question
Consider linked list is used to implement the Stack then which of the following node is considered as Top of the Stack ?
Answer
  • Any Node
  • Last Node
  • First Node
  • Middle Node

Question 25

Question
Consider the following linked list representation - struct node { int data; struct node *next; }start = NULL; struct node *new_node; Which of the following statement is used to create a node ?
Answer
  • new_node=(struct node *)malloc((struct node));
  • new_node=(struct *)malloc(sizeof(struct node));
  • new_node=(struct node)malloc(sizeof(struct node));
  • new_node=(struct node *)malloc(sizeof(struct node));

Question 26

Question
Which of the following data structure is linear type?
Answer
  • Strings
  • Lists
  • Queues
  • All of above

Question 27

Question
In a Heap tree
Answer
  • Values in a node is greater than every value in left sub tree and smaller than right sub tree
  • Values in a node is greater than every value in children of it
  • Both of above conditions applies
  • None of above conditions applies

Question 28

Question
The order of an algorithm that finds whether a given Boolean function of 'n' variables, produces a 1 is
Answer
  • linear
  • constant
  • exponential
  • logarithmic

Question 29

Question
A list integers is read in, one at a time, and a binary search tree is constructed. Next the tree is traversed would result in a printout which duplicates the original order of the list of integers?
Answer
  • Inorder
  • Preorder
  • Postorder
  • None of these

Question 30

Question
A characteristic of the data that binary search uses but the linear search ignores, is
Answer
  • Maximum value in the list
  • Minimum value in list
  • Length of the list
  • Order of the list

Question 31

Question
Queue can be used to implement
Answer
  • recursion
  • radix sort
  • quick sort
  • depth first search

Question 32

Question
Which of the following sorting methods sorts a given set of items that is already in sorted order or in reverse sorted order with equal speed?
Answer
  • Heap sort
  • Quick sort
  • Selection sort
  • Insertion sort

Question 33

Question
Suppose DATA array contains 1000000 elements. Using the binary search algorithm, one requires only about n comparisons to find the location of an item in the DATA array, then n is
Answer
  • 7
  • 20
  • 38
  • 45

Question 34

Question
A sort which iteratively passes through a list to exchange the first element with any element less than it and then repeats with a new first element is called
Answer
  • heap sort
  • quick sort
  • selection sort
  • insertion sort

Question 35

Question
The maximum number of comparisons needed to sort 7 items using radix sort is (assume each item is 4 digit decimal number)
Answer
  • 23
  • 110
  • 280
  • 450

Question 36

Question
The postfix equivalent of the prefix * + a b - c d is
Answer
  • ab+cd-*
  • ab + cd * -
  • ab + - cd *
  • ab cd + - *

Question 37

Question
A complete binary tree with the property that the value at each node is at least as large as the values at its children is called
Answer
  • Heap
  • Binary Tree
  • Binary search tree
  • Completely balanced tree

Question 38

Question
A full binary tree with n leaves contains
Answer
  • n nodes
  • log2n nodes
  • 2n+1 nodes
  • 2n - 1 nodes

Question 39

Question
Traversing a binary tree first root and then left and right subtrees called _______traversal.
Answer
  • inorder
  • preorder
  • postorder
  • none of these

Question 40

Question
The number of nodes in a complete binary tree of level 5 is
Answer
  • 10
  • 21
  • 63
  • 77

Question 41

Question
Number of possible binary trees with 3 nodes is
Answer
  • 5
  • 7
  • 9
  • 11

Question 42

Question
A binary tree is generated by inserting in order the following integers: 50, 15, 62, 5, 20,58, 91, 3,8,37, 60, 24 The number of nodes in the left of the root respectively is
Answer
  • (3,6)
  • (4,7)
  • (6,3)
  • (7,4)

Question 43

Question
The depth of a complete binary tree with n nodes is (log is to be base two)
Answer
  • log(n)
  • log(n) + 1
  • log (n-1) + 1
  • log (n+1)-1

Question 44

Question
Which of the following are valid characters for a numeric literal constant?
Answer
  • a comma ( , )
  • a dollar sign ($)
  • a percent sign (%)
  • None of the above

Question 45

Question
A default catch block catches
Answer
  • all thrown objects
  • no thrown objects
  • any thrown object that has not been caught by an earlier catch block
  • all thrown objects that have been caught by an earlier catch block

Question 46

Question
When the compiler cannot differentiate between two overloaded constructors, they are called
Answer
  • overloaded
  • destructed
  • ambiguous
  • dubious

Question 47

Question
When you pass a variable _____, C++ passes only the contents of the variable to the receiving function
Answer
  • by reference
  • by value
  • globally
  • locally

Question 48

Question
Paying attention to the important properties while ignoring inessential details is known as________
Answer
  • selectiveness
  • polymorphism
  • abstraction
  • summarizing

Question 49

Question
When you omit parameters from a function call, values can be provided by
Answer
  • formal parameters
  • reference parameters
  • overloaded parameters
  • default parameters

Question 50

Question
The items listed in the function header are called _____
Answer
  • actual arguments
  • formal parameters
  • passed parameters
  • sent arguments
Show full summary Hide full summary

Similar

Bio Psyc Weeks 8-11: Emotion, Motivated Behaviours I: Reproductive Behaviours, Motivated Behaviours II – Sleep, Psychological Disorders
Karis Allen
The American Revolution
Ger McCabe Kelly
Supply-side Ecology
chloe allen
Developmental MCQ's
Karis Allen
WEEK 2 REVIEW QUESTIONS - EVOLUTIONARY THEORY
Emma Taurere
Disturbance
chloe allen
Biogenic Habitat & Engineers
chloe allen
plant and animal interactions
chloe allen
Aquaculture problems
chloe allen
government expenditure
sarah2013
Personality & Individual Differences Weeks 7-12
Karis Allen