Data Structures Quiz 2

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

How many elements do we eliminate after each comparison in linear search on an array? A. 1 element B. half the set of elements C. 2 or more elements

A. 1 element

What is the maximum number of nodes at level i of a binary tree, assuming that the root is at level 1? A. 2^(i-1) B. 2^(i-1)+1 C. 2^i D. 2^(i+1)

A. 2^(i-1)

In a linked list, the elements are linked forming: A. A chain B. A circle

A. A chain

Which one of the ways to traverse a tree below, first visits the left child of the root, then the root and then its right child? A. Inorder traversal B. Preorder traversal C. Postorder traversal

A. Inorder traversal

The last node in a linked list has a pointer to: A. NULL B. the first node of the list C. the previous node

A. NULL

Consider a maximum heap of n nodes. What is the time complexity of accessing the maximum element of this heap? A. O(1) B. O(n) C. O(n^2) D. O(logn)

A. O(1)

Consider a maximum heap of n nodes. What is the time complexity of accessing a leaf (i.e., a node without children) of this heap? A. O(logn) B. O(1) C. O(n)

A. O(logn)

A heap is: A. a complete binary tree B. a full binary tree

A. a complete binary tree

What will be the elements on stack s, reading them from the bottom to the top, after the following code snippet is executed? s.push(a); s.push(b); s.pop(); s.push(c); A. ac B. acb C. c D. abc

A. ac

Given a queue, we can delete an element from: A. the front of it B. the rear of it C. any position of it

A. the front of it

In which of the following cases you would prefer to use a linked list instead of an array? Choose ALL these cases (they may be more than one). A. When we need to index or randomly access elements frequently. B. When we do not know the exact number of elements beforehand. C. When we need speed while iterating over the elements in the sequence. D. When we know the number of elements we are going to use beforehand in order to allocate the right amount of memory. E. When we know that there will be a large number of insertions or removals of elements. F. When we want to insert items anywhere in the structure, frequently.

B. When we do not know the exact number of elements beforehand. E. When we know that there will be a large number of insertions or removals of elements. F. When we want to insert items anywhere in the structure, frequently.

Consider a 2-dimensional array stored in the memory of our computer, consisting of m rows and n columns. If the first column of the array is entirely saved in memory, followed by the second column, and so on until the last column of the array, we can imply that the ordering that was used for storing the array is the: A. ordering by ascending order of the first element of each column B. column-major ordering C. row-major ordering D. ordering by ascending order of the first element of each row

B. column-major ordering

Given a stack, we can pop an element: A. only from the bottom of it B. only from the top of it C. from any position of it, depending on the implementation

B. only from the top of it

In a linked list, the links between the elements are implemented using: A. objects B. pointers C. arrays

B. pointers

In a circular queue of size n, the value of 'rear' should be (% is the modulo operator): A. rear = (rear + 1) % (n+1) B. rear = (rear + 1) % n C. rear = rear + 1 D. rear = (rear - 1) % (n-1)

B. rear = (rear + 1) % n

Which level(s) of a heap may contain less nodes than the maximum possible number for that level? A. any level except from the last one B. the last level C. any level

B. the last level

Given a queue, we can insert an element at: A. any position of it B. the rear of it C. the front of it

B. the rear of it

How many parents can a node of a tree have? A. exactly 1 B. 0, 1 or more C. 0 or 1

C. 0 or 1

How many children can a node in a binary tree have? A. exactly 1 B. 0 or 1 C. 0, 1 or more

C. 0, 1 or more

How many children can a node of a tree have? A. exactly 1 B. 0 or 1 C. 0, 1 or more

C. 0, 1 or more

Which of the following statements are correct? 1. Using simple linked lists and circular linked lists, it is not possible to traverse the list backwards. 2. To find the previous of an element in a simple linked list, it is required to traverse the list starting from the first element. A. Neither 1 nor 2 B. 1 only C. Both 1 and 2 D. 2 only

C. Both 1 and 2

How many index variables are needed to locate an element in a multi-dimensional array? A. Exactly one B. More than two C. More than one D. Exactly two

C. More than one

In which of the following scenarios you would using an array be the best option? 1. For cases where the size of the data structure and/or the data in the structure are constantly changing. 2. For relatively permanent collections of data. A. Only in scenario 1 B. In none of the scenarios 1 and 2 C. Only in scenario 2 D. In both scenarios 1 and 2

C. Only in scenario 2

Which of the data structures below is non-linear, with regards to the access on its elements? A. Stack B. Queue C. Tree D. Doubly Linked List

C. Tree

Consider an array data structure. Can we have direct access to some element of it? A. Maybe. It depends on the type of data stored in the array. B. No, we have to traverse the array until we reach the desired position. C. Yes, by using its index number.

C. Yes, by using its index number.

When a list is empty, its head is: A. a node with no pointer to other node B. a node that has the pointer to NULL C. a NULL pointer

C. a NULL pointer

How many elements do we eliminate after each comparison of a binary search on an array? A. c elements, with c>1 B. one element C. half the set of elements

C. half the set of elements

Given a stack, we can push an element: A. at any position of it, depending on the implementation B. only at the bottom of it C. only at the top of it

C. only at the top of it

What is the maximum number of nodes in a binary tree of height k? A. 2^(k-1) B. 2^(k+1)-1 C. 2^(k-1)+1 D. 2^k-1

D. 2^k-1

Consider an array data structure. Which of the following statements are correct? 1. The data stored in it can be of various data types. 2. The data are stored at contiguous memory locations. A. Both 1 and 2 B. Only 1 C. Neither 1 nor 2 D. Only 2

D. Only 2

(TF)A binary search tree is allowed to violate the ordering property of a binary search tree at some instances of time.

False

(TF)A circular linked list allows traversal of the data elements in both directions (left to right and vice versa).

False

(TF)A linked list is not a dynamic data structure.

False

(TF)A queue follows a LIFO (Last In First Out) approach for accessing elements.

False

(TF)An array is a dynamic data structure.

False

(TF)Every binary tree is a binary search tree.

False

(TF)In a doubly-linked list, every element has two links to other elements.

False

(TF)In a linked list, the elements are stored in adjacent memory locations.

False

(TF)The efficiency of the functions, operations or algorithms that we apply on our data is independent of the data structures that we use.

False

(TF)When using a linked list, do we waste memory by allocating it at the beginning of the execution of a program (i.e., not based on the needs of the program)?

False

A binary tree is generally partitioned into three disjoint subsets of nodes, i.e., the _____ of the tree, the _____ sub-tree and the _____ sub-tree.

Root, Left, Right OR Root, Right, Left

(TF) In a circular linked list, every element has a link to another element.

True

(TF)A linked list has the ability to grow and shrink on demand.

True

(TF)A stack follows a LIFO (Last In First Out) approach for accessing elements.

True

(TF)Binary search can be performed on an array only if it is sorted.

True

(TF)Every subtree of a binary search tree is a binary search tree itself.

True

(TF)In an objected oriented language like C++ or Java, data structures are implemented by using classes and objects.

True

(TF)The core concepts of data structures remain the same across all the programming languages. Τheir implementation differs, based on the syntax or the structure of each programming language.

True

(TF)We use data structures for the efficient organization and modification of data.

True

(TF)When using an array, do we waste memory by allocating it at the beginning of the execution of a program (i.e., not based on the needs of the program)?

True

The first element of a linked list is called __________.

head

Which of the data structures below is more efficient with regards to inserting/deleting elements to/from it? A. An array B. A linked list

B. A linked list

Which of the following data structures cannot store non-homogeneous data elements? A. Stacks B. Arrays C. Queues D. Linked Lists

B. Arrays

Consider a minimum heap of n nodes. What is the time complexity of accessing the maximum element of this heap? A. O(1) B. Definitely larger than O(1)

B. Definitely larger than O(1)

An OVERFLOW message is printed if we attempt to: A. Pop an element out of an empty stack B. Push an element into a full stack C. Peek an element out of a non-empty stack

B. Push an element into a full stack


Set pelajaran terkait

Vertex of Quadratics in Standard Form

View Set

Business Communication final exam study guide.

View Set

APUSH terms: Franklin, Benjamin-Fugitive Slave Act

View Set

Tableau Essential Training—LinkedIn

View Set

Les mots de la lettre de motivation - list motywacyjny

View Set

objectives chapter 10 & 8 Essentials for Nursing

View Set

Rosetta Stone French Level 2, Unit 1, Lesson 3

View Set