CSD HardCore

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

The memory address of fifth element of an array can be calculated by the formula

LOC(Array[5]=Base(Array)+w(5-lower bound), where w is the number of words per memory cell for the array

Explain LIFO

Last-In-First-Out. A stack is a LIFO storage mechanism because the last item inserted is the first one to be removed.

Each entry in a linked list is called a

Link

Each entry in a linked list is called a _______

Link

Which one of the following is an application of Stack Data Structure?

Managing function calls, The stock span problem, Arithmetic expression evaluation.

Which of the following expressions evaluates to true with approximate probability equal to P? (P is double and 0 <= P <= 1).

Math.random() < P

Which of the following sorting algorithm is of divide and conquer type?

Merge sort

Whatever you can do to manipulate the data storage structure becomes our:

Methods.

A recursive method is a method that invokes itself directly or indirectly. For a recursive method to terminate there must be one or more base cases.

Most Correct

Select the statement that is most correct. Which of the following applications may use a queue?

Multi-programming

which following applications may use a queue?

Multi-programming

Which of the following data structure is non-linear type?

None of above

Which of the following data structure is non-linear type?

None of string,list,stack

In the array version of the Stack class, which operations require linear time for their worst-case behavior?

None of these operations require linear time.

In the circular array version of the Queue class, which operations require linear time for their worst-case behavior?

None of these operations require linear time.

In the linked-list version of the Stack class, which operations require linear time for their worst-case behavior?

None of these operations require linear time.

Which of the following case does not exist in complexity theory

Null case

The complexity of linear search algorithm is

O(n)

order is the best possible for array sorting algorithm which sorts n item.

O(n+logn)

The complexity of Bubble sort algorithm is

O(n2)

The complexity of bubble sort algorithm is

O(n2)

specify the correct implementation of pop() method of a stack. this stack uses java.util.ArrayList for storing data and the end of the list is treated as the top of the stack.

Object pop(){if(isEmpty())return(null);return(pool.remove(pool.size()-1));}

To evaluate an expression without any embedded function calls:

One stack is enough.

I have implemented the queue with a linked list, keeping track of a front node and a rear node with two reference variables. Which of these reference variables will change during an insertion into a NONEMPTY queue?

Only rear changes

A variable P is called pointer if

P contains the address of an element in DATA

A variable P is called pointer if

P contains the address of an element in DATA.

What is the "push"?

Placing a data item on top of the stack.

What are the pros and cons of using a priority queue implemented by a simple array?

Pro: Simple and appropriate when the # of items isn't high or insertion speed isn't critical.

One difference between a queue and a stack is:

Queues use two ends of the structure; stacks use only one.

bitRadixsort() can be improved by implementing array , One of techniquesradix sort uses is by looking at each

Radix sort

is the method used by card sorter.

Radix sort

Which of the following data structure store the non-homogeneous data elements?

Records

An algorithm that calls itself directly or indirectly is known as

Recursion

What is "popping"?

Removing a data item from the top of the stack.

Which operation is used in DSW Algorithm:

Rotation

Specify the reason for data compression (select the best answer):

Saving data storage

Each data item in a record may be a group item composed of sub-items; those items which are indecomposable are called

Scalars, atoms, elementary items

Finding the location of the element with a given value is

Search

Finding the location of the element with a given value is:

Search

If the number of records to be sorted is small, then...sorting can be efficient.

Selection

Which of the following sorting algorithm is of priority queue sorting type?

Selection sort

Elements of an array are stored _______ in memory

Sequentially

Elements of an array are stored in memory

Sequentially

In a _____every element contains some data and a link to the next element, which allows to keep the structure

Singly linked list

What is the value of the postfix expression 6 3 2 4 + - *:

Something between -15 and -100

_________ is the way you groups things together by placing one thing on top of another and then removing things one at a time from the top

Stack

is the way you groups things together by placing one thing on top of another and then removing things one at a time from the top

Stack

Pushdown list means:

Stack , Queue, Linked list

which of the following applications may use a queue

Store a waiting list of printing

Select the statement that is most correct.Which of the following applications may use a stack?

Store a waiting list of printing jobs

Which of the following applications may use a stack?

Store a waiting list of printing jobs

In a singly-linked list, these is no efficient way to insert node before a given node in the middle or at the end of the list

T

Select the most correct statement about the complexity of bubble sort *

The best case is 0(n). and the worst case is 0(n~2)

Select the most correct statement about the complexity of insertion sort

The best case is 0(n). and the worst case is 0(n~2)

Select the most conect statement about the complexify of insertion sort

The best case is 0(nlogn). and the worst case is 0(n~2)

Select the most correct statement about the complexity of merge sort

The best case is O(n^2), and The worst case is O(nlogn)

Select the most correct statement about the complexity of insertion sort

The best case is O(nlogn), and the worst case is O(n^2)

When converting a method from a recursive version into an iterative version

The brevity of program formulation lost. However, the brevity may not bean issue in Java , Program clarity can be diminished

Consider the implementation of the Queue using a circular array. What goes wrong if we try to keep all the items at the front of a partially-filled array (so that data[0] is always the front).

The getFront method would require linear time.

In the linked list version of the Bag class an instance variable manyNodes is used to keep track of how long the linked list is. Why not just make a call to the IntNode method listLength()?

The listLength() method is O(n) and the alternative is O(1).

void fun(int n){if(n>0) {System.out.print(" "+ n%5); fun(n); } } What will happen if the statement fun(33): is run?

The operating system detects the infinite recursion because of the "repeated state"

Suppose that obj is an Object variable and that it refers to an Integer object. If s is a String variable, then which statement is correct about the assignment "s = (String) obj;"?

The statement will compile, but there will be a run-time exception.

Consider the binary tree below. Which statement is correct?

The tree is full but not complete.

Consider the binary tree below. Which statement is correct? (full binary tree = proper binary tree = 2-tree)

The tree is neither complete nor full.

Entries in a stack are "ordered". What is the meaning of this statement?

There is a first entry, a second entry, and so on.

Which of the following is not the required condition for binary search algorithm?

There must be mechanism to delete and/or insert elements in list

What happens to non delimiter characters?

They are not inserted onto the stack; they are ignored.

In a binary tree, certain null entries are replaced by special pointers which point to nodes higher in the tree for efficiency. These special pointers are called

Thread

What is written to the screen for the input "HowAre**YouTo***Day" ?

ToDay

The operation of processing each element in the list is known as

Traversal

Which of the following methods are used to traverse a tree without using anystack or threads:

Traversal through tree Transformation

To represent hierarchical relationship between elements, which data structure is suitable

Tree

To represent hierarchical relationship between elements, which data structure is suitable?

Tree

Which of the following data structure is non linear data structure?

Trees

A recursive method is a method that invokes itself directly or indirectly. For a recursive method to terminate there must be one or more base cases

True

An object can be saved in a life if its class type is stated, If the vectors capacity is greater than its size, then a new elem

True

Arrays are dense lists and static data structure

True

For a binary tree with n nodes, there are n! different traversals, The complexity of searching depends on the shape of the tree and the,Breath-First traversal

True

If hash function transforms different keys into different numbers, it iscalled a perfect hash function

True

In Huffman coding, both the sender and receiver must have a copy of the same code in order for the decoded file to match the encoded file.

True

In a linked list, the tail node is introduced for performance purpose only.

True

In a singly-linked list every element contains some data and a link to the next element, which allows to keep the structure

True

In a singly-linked list there is no efficient way to insert a node before a given node in the middle of the list (the action is considered efficient if it's complexity is 0(1)).

True

In a singly-linked list we can insert a node after a given node with time complexity 0(1)

True

In a singly-linked list, there is no efficient way to insert a node before a given node in the middle or at the end of the list, but we can insert a node after a given node or at the beginning of the list with time complexity O(1)

True

In shift folding method, the key is usually divided into even, The boundary folding method is applied to number data

True

In the array implementation, enqueuing can be executed in constant time O(1)

True

Integer pop(){ if(isEmpty) return(null); return((Integer)pool.remove(pool.size()-1)); }

True

Object dequeue() {if (isEmpty()) return(null); return(pool.remove(0));}

True

Polish notation eliminates all parentheses from formu, Using Polish notation, all expressions have to be brok,Expression trees do not use

True

Recursive definitions on most computers are eventually implemented using a run-time stack and this implementation is done by the operating system.

True

Run-length encoding is very efficient for text file in which only blank character has a tendency to be repeated without using any technique

True

data elements in linked list need not be stored in adjecent space in memory

True

in linked list, the tail node is introduced for performance purpose only

True

linked lists are collection of the nodes that contain information part and next pointer

True

void enqueue(Object x){Node p = new Node(x); p.next = null; if(isEmpty()) head = tail = p; else {tail.next = p; tail = p;}}

True

void inOrder(Node p){ if(p != null){ inOrder(p.left); visit(p); inOrder(p.right);} }

True

void push(Integer x){ Node p = new Node(x); p.next = head; head=p; }

True

The Java implementation of the stack is potenti, Stack can be implemented by linked list

True about Stack

The most top element is the latest added element , Operations of stack based on Last in First out structure.

True about Stack

Deleting a node at the beginning of th ...time O(1) - On the average,delete operatio... O(n) steps, There is no immediate access to the predecessorof any node in list

True about singly linked list

The height of a nonempty tree is the maximum level of node ,The level ofa node is the length of the path from the root to the node plus 1,The level ofa node must be between 1 and height of the tree

True about tree

Which of the following applications may use a stack?

Undo sequence in a text editor

In a Heap tree

Values in a node is greater than every value in children of it

What is a primary difference between an array and a Vector from Java's Class Libraries:

Vectors grow automatically as needed.

The complexity of DFS is O(

V| + |E|), where |V| is number of ve, To prevent loop from happen in an algorithm for traversing a grahp | True

The complexity of sequential Coloring algorithm is O(

V|2) ,Sequential Coloring algorithm establishes the sequence of | True about Graph coloring

Which of the following can be executed in constant time O(n)

When deleting a node of a singly linked list in the average case , in the worst case

What is wrapping around? When is it useful? What is created that must be fixed?

Wrapping around allows the user to fill in new items in the queue at index zero, assuming that the queue is empty at index zero. This creates a broken sequence (the items in the queue are in two different sequences in the array).

How does the mail sorting analogy apply to the priority queue?

You insert a letter from the postman into your pile of pending letters according to priority. The higher the priority the higher the position in the pile.

Value of the first linked list index is

Zero

Value of the first linked list index is _______

Zero

A connected graph T without any cycles is called

a tree graph & free tree & a tree

The size of a structure can be determined by

a. size of variable name + b. size of (struct tag)

Suppose that the Bag is implemented with a linked list. Which of these operations are likely to have a constant worst-case time?

add

The difference between linear array and a record is

all

Each data item in a record may be a group item composed of sub-items; those items which are indecomposable are called

all of above

In a graph if e=[u, v], Then u and v are called

all of above

Each data item in a record may be a group item composed of sub-items; those items which are indecomposable are called

all: elementary ,atom,scalar

A linked list index is ____ that represents the position of a node in a linked list.

an Integer

A linked list index is that represents the position of a node in a linked list.

an Integer

A linked list index is ____ that represents the position of a node in a linked list.

an integer

What member function places a new node at the end of the linked list?

appendNode()

In an array queue, data is stored in an _____ element.

array

Consider a graph below. Cut-vertices in the graph are

b, c, e

New nodes are added to the _____ of the queue.

back

The memory address of the first element of an array is called

base address

Why is the constructor of the LinkedList class empty?

bc...of the LinkedList class is ...constructor of the LinkedList class.

Why is the constructor of the LinkedList class empty?

because initialization of data members of the LinkedList class is performed by the constructor of the LinkedList class.

select the most correct statement about the complexity of bubble sort

best case 0(n), worst case 0(n^2)

select the most correct statement about the complexity of insertion sort

best case O(n), worst case 0(n^2)

Which of the following is not a limitation of binary search algorithm?

binary search algorithm is not efficient when the data elements are more than 1000.

select the most correct statement about the complexity of heapsort

both best and worst 0(nlogn)

Two dimensional arrays are also called

both of above: table,matrix

A _______ is a data structure that organizes data similar to a line in the supermarket, where the first one in line is the first one out.

both of them

A is a data structure that organizes data similar to a line in the supermarket, where the first one in line is the first one out.

both of them

A binary tree can easily be converted into q 2-tree

by replacing each ... new external node

A binary tree can easily be converted into q 2-tree

by replacing each empty sub tree by a new external node

The elements of an array are stored successively in memory cells because

by this way computer can keep track only the address of the first element and the addresses of other elements can be calculated

If every node u in G is adjacent to every other node v in G, A graph is said to be

complete

If every node u in G is adjacent to every other node v in G, a graph is said to be

complete

I have implemented the queue with a circular array, keeping track of front, rear, and manyItems (the number of items in the array). Suppose front is zero, and rear is one less than the current capacity. What can you tell me about manyItems?

count could be zero or the capacity, but no other values could occur.

Suppose we have a circular array implementation of the queue class, with ten items in the queue stored at data[2] through data[11]. The current capacity is 42. Where does the insert method place the new entry in the array?

data[12]

To delete a dynamically allocated array named `a`, the correct statement is

delete a;

the operator for removing and returning the end element of the queue is traditionally called

dequeue

which of following queue operations cold result in queue underflow

dequeue

which of the following queue operations could result in queue underflow (become empty)?

dequeue

A record form a hierarchical structure but a lienear array does not

difference bw linear and record

An array is suitable for homogeneous data but hte data items in a record may have different data type

difference bw linear and record

In a record, there may not be a natural ordering in opposed to linear array.

difference bw linear and record

What is written to the screen for the input "Good**Mor*ni***ng"?

dorino

a node contains some data and one link to its successor and one link to its predecessor in the list

double linked list

A _____ node contains some data and one link to its successor and one link to its predecessor in the list.

doubly linked list

Which of the following is two way list?

doubly linked list

In a graph if e=(u, v) means

e begin, u is profe

In a graph if e=(u, v) means

e begins at u and ends at v

In a graph if e=(u, v) means

e begins at u and ends at v & u is processor and v is successor

Insertion sort is applied to small portions of an array, Mergesort can be made more efficient by replacing

efficient sorting

Each data item in a record may be a group item composed of sub-items; those items which are indecomposable are called

elementary items & atoms & scalars

In a graph if e=[u, v], Then u and v are called

endpoints of e & adjacent nodes & neighbors

In a graph if e=[u, v], Then u and v are called

endpoints,adjacent node,neighbors

The operation for adding an entry to a queue is traditionally called

enqueue

The operation for adding an entry to a queue is traditionally called:

enqueue

the operator for adding an entry to a queue is traditionally called

enqueue

Unlike a stack, the items in a queue don't always:

extend all the way down to index 0.

Run the length encoding is a lossless compression method in which repeated occurrences of a symbol are replaced by one occurrence of the symbol followed by the number of occurrences.

false

Arrays are best data structures

for relatively permanent <benvung> collections of data

Arrays are best data structures

for relatively permanent collections of data

Arrays are the best data structures

for relatively permanent collections of data

arrays are the best data structures

for relatively permanent collections of data

linked list are best suited

for relatively permanent collections of data

Linked lists are best suited

for relatively permanent collections of data.

Linked lists are best suited

for the size of the structure and the data in the structure are constantly changing

I have implemented the queue with a linked list, keeping track of a front node and a rear node with two reference variables. Which of these reference variables will change during an insertion into an EMPTY queue?

front changes., rear changes.

int fun(int n) {if(n<0) return(fun(-n)); else if(n<5) return(2); else return(n*fun(n-2)); } Which call will result in the most recursive calls?

fun(-1012);

void fun(int n) {if(n < 0) {System.out.println("-"); fun(-n); } else if(n<10) System.out.println(n); else {fun(n/10); System.out.println(n%10); } } Which call will result in the most recursive calls?

fun(-1023)

Consider the following function: void fun(int n) {if (n<0) {System.out.println("-"); fun(-n); } else if(n<10) System.out.println(n); else {fun(n/10); System.out.println(n%10); } } Which call will result in the most recursive calls?

fun(-1023);

which call will result in the most recursive calls ?

fun(-1025)

The _______ function retrieves the value of the size member of the LinkedList class

getSize()

The function retrieves the value of the size member of the LinkedList class

getSize()

Which of the following is two way list?

grounded header list;circular header list;linked list..nodes=False

correct statement about hasing algorithm

if the coalesced method is used for collision resolution, insertion and searching always take constant time 0(1)

specify the correct statement about chaining method for handling collision

in chaining, only some possition of the table is associated with a linked list of chain of structrures whose info fields strore keys or references to keys

Give a weighted graph below and you are using the Dijkstra algorithm to find the sortest path from the vetex H to the vertex T. What is the label of the vertex D when the shortest path from H to T is determined?

infinity

Node q = new Node(x); q.next = head; head = q;

inserts new node with value x at the head of the list

When converting binary tree into extended binary tree, all the original nodes in binary tree are

internal nodes on extended tree

what is the correct definition of a hash table?

is a array in memory used ... into an index i=h(x) in the table

The pop() member function determines if the stack is empty by calling the _____ member function

isEmpty()

The pop() member function determines if the stack is empty by calling the member function

isEmpty()

What is written to the screen for the input "FileComp****ress*ion**" ?

iserCeliF

Node p1,p2; p1 = p.next; p2 = p1.next; p.next = p2; if(p2!=null) p2.prev=p;

it deletes the node after p.

Node f = head; while(f.next !=p) f = f.next; f.next = p.next;

it deletes the node p.

Suppose we are considering a doubly linked list and p is some node in the list which has successor node. What does the java code snippet below do? Node p1, p2; p1 = new Node(x); p2 = p.next; p.next = p1; p1.prev = p; p1.next = p2; p2.prev = p1;

it inserts new node with value x after the node p.

Node q = new Node(x); q.prev=null; q.next = head; head.prev = q; head = q;

it inserts new node with value x at the head of the list.

which of following applications may use a queue

keeping track of local variables at run time

Which of the following data structures are indexed structures?

linear arrays

Multi-programming.

may use a queue

Store a waiting list of printing jobs.

may use a queue

What values of n are directly handled by the stopping (base) case?

n==0&& n<35

What values of n are directly handled by the stopping (base) case?

n>=0 && n<15

void fun(int n){if(n < 0) {System.out.println("-"); fun(-n);} else if(n<15) System.out.println(n); else {fun(n/15); System.out.println(n%15); } }

n>=0 && n<15

Which of the following case does not exist in complexity theory

null case

What is written to the screen for the input "Go**od**Mor*ni*ng*Sir"?

oGdorig

Suppose that obj is an Object variable and s is a String variable. Which of the following statements is a correctly-compiling widening conversion? Don't worry about possible run-time exceptions.

obj = s

When new data are to be inserted into a data structure, but there is no available space; this situation is usually called

overflow

Binary search algorithm cannot be applied to

pointer array\sorted linear array

To create a linked list, we can allocate space and make something point to it, by writing: struct-name *pointer-variable; Which of the following statement will correctly allocate the space

pointer-variable = malloc(sizeof(struct struct-name));

Which of the following statement is false?

pointers store the next data element of a list

A operation for moving and returning the top element of the stact is traditionally called

pop

The operation for removing an entry from a stack is traditionally called:

pop

The operation for removing and returning the top element of the stack is traditionally called:

pop

Which of the following stack operations could result in stack underflow?

pop

Integer pop() { if(isEmpty()) return (null); return((Integer)pool.removeLast()); }

pop() method of a stack of Integers.

void preOrder(Node p){ if(p = null) { visit(p); preOrder(p.left); preOrder(p.right); } }

pre-order traverse algorithm

The operation for adding an entry to a stack is traditionally called:

push

A _______ is a data structure that organizes data similar to a line in the supermarket, where the first one in line is the first one out.

queue linked list

A is a data structure that organizes data similar to a line in the supermarket, where the first one in line is the first one out.

queue linked list

Partition and exchange sort is

quick sort

What is written to the screen for the input "Go**odMorn**in***gSir"?

riSgMdo

A Linked list can grow and shrink in size dynamically at

run time

A Linked list can grow and shrink in size dynamically at _______

run time

The complexity of sorting algorithm measures the ...... as a function of the number n of items to be sorter.

running time

specify the reason for data compression

saving data strorage

in a every element contains some data and a link to the next element, which allow to keep the structure

singly linked list

specify thof the e correct statement about chaining method for handling collision

some possition of the table is associated with a linked list or chain of structures whose info fields store keys or references to keys

Binary search algorithm can not be applied to

sorted binary trees

Binary search algorithm cannot be applied to

sorted binary trees

binary tree algorithm cannot be applied to

sorted linear array

Binary search algorithm can not be applied to

sorted linked list

Binary search algorithm can not be applied to

sorted singly linked list

Two dimensional arrays are also called

tables arrays && matrix arrays

Each array declaration need not give, implicitly or explicitly, the information about

the first data from the set to be store

Each array declaration need not give, implicitly or explicitly, the information about

the first data from the set to be stored

What happens when you push a new node onto a stack?

the new node is placed at the front of the linked list.

When representing any algebraic expression E which uses only binary operations in a 2-tree,

the variable in E will appear as external nodes and operations in internal nodes

In a binary tree, certain null entries are replaced by special pointers which point to nodes higher in the tree for efficiency. These special pointers are called

thread

If the two stacks are implemented on a single array, the overflow occurs at

top1=top2 && top1=top2-1

To represent hierarchical relationship between elements, which data structure is suitable?

tree

A connected graph T without any cycles is called

tree graph,free tree,a tree

In a linked list, the tail node is introduced for performance purpose only

true

in a singly-linked list there is no effecient way to insert a node before a given node in the middle of the list

true

in a singly-linked list we can insert a node after a given node with time complexity O(n)

true

The situation when in a linked list START=NULL is

underflow

which of following applications may use stack?

undo sequence in a text editor, auxiliary data structure for algorithms

which of the following applications may use a stack

undo sequence in the text editor

Which of the following data structure is linear type?

(Strings, Lists, Stacks)= True.

What is the expression for generating a pseudorandom number in the range 1...N?

(int) (Math.random() * N) + 1;

If data is a circular array of CAPACITY elements, and rear is an index into that array, what is the formula for the index after rear?

(rear + 1) % CAPACITY

void fun(int n) {if (n <=0) System.out.println("That's all!"); else {for(int i = 1; i <= n; i++) System.out.print("*"); System.out.println(); fun(n - 2); } } What is the output when the statement fun(5); is run?

*(/n)***(/n)*****(/n)That's all!

Consider the implementation of the Stack using a partially-filled array. What goes wrong if we try to store the top of the Stack at location [0] and the bottom of the Stack at the last used position of the array?

. Both push and pop would require linear time.

What is the correct definition of a hash table?

...used for storing items or their addresses... i = h(x) in the table.

6, 4, 7, 3, 5, 2 What is the balance factor of the node 4?(please note that the tree is still AVL)

0

How many stack will be needed for the evaluation of a prefix expression

0

To implement an AVL tree, a concept balance factor is introduced (bal = height(right)-height(left). Suppose an AVL tree is created by inserting to the tree the following keys sequentially: 6,4,7,3,5,2 What is the balance factor of the node 4? (please note that the tree is still AVL)

0

void fun(int n) {if(n > 0) { n = n/5; fun(n); System.out.print(" " + n); } } What is the output when the statement fun(23); is run?

0 4

the complexity of countting the number of items in a doubly-linked list

0(n)

Given the character frequencies B : 32% C : 28% D : 16% E : 6% F : 18% Using Huffman encoding, what is the code for character C?(Suppose that when constructing a sub tree from 2 nodes we always place node with higher frequency on the left, and the left branch of a node gets value 0, the right one gets value 1)

01

void fun(int n) {if(n > 0) { fun(n-2); System.out.print(" " +n ); } } What is the output when the statement fun(9); is run?

1 3 5 7 9

Suppose a doubly linked list of integers is given below and p is a reference to the node with value 15 in the list(i.e. p.info=15): (head)7 11 6 4 3 15 8 12(tail) What does the list look like after the following java code snippet is run?

7 11 6 4 3 35 15 8 12

What is the result of the breadth first traverse of the binary search tree T, after inserting the following keys into the tree sequentially(suppose T is empty before insertion): 7, 8, 4, 1, 3, 6, 9

7 4 8 1 6 9 3

What is the value of the Shift Folding Hash Function if K = 43-65-69-7 and TSize = 100?

84

what is the value of the Shift Folding Hash Function if K = 43-65-69-7 and Tsize = 100

84

what is the value of the shift folding hash function if K= 43-65-69-7 and Tsize = 100?

84

What is value of the Boundary Folding Hash Function if K = 43-57-69 and TSize = 100?

87

what is the value of the Boundary Folding Hash Function if K = 43-57-69 and Tsize = 100

87

what is the value of the Boundary Folding Hash Function if K = 45-65-79-8 and Tsize = 100

88

How is a priority queue different than a queue?

A priority queue items are ordered by key value so that the item with the lowest key ( or in some implementations the highest key) is always at the front. Items are inserted in the proper position to maintain the order.

(1) Put the vertex X to H (2) Check if H is a Hamilton cycle the stop, else go to (3) (3) Consider the last vertex Y in H, if there is/are vertex(es) adjacent to Y, select the first adjacent vertex Z (by alphabet order) and put it to H. if there no adjacent vertex, remove Y from H and denote it as bad selection (so you do not select it in the same way again). Go to (2)

A, B, C, E, D, A

Suppose you are using the LZW algorithm to encode the message AABCADAB contents of the dictionary at the beginning of encoding are: (1) A (2) B (3) C (4) D What string is denoted by code word (5)7

AA

Using the Huffman code tree below. What is the result of decoding the string: 1100000001100 ?

AABBBCAB

10000010011

ABBCD

Using the Huffman code tree below. What is the result of decoding the string: 10000010011?

ABBCD

The post order traversal of a binary tree is DEBFC Find out the pre order traversal

ABDECF

The post order traversal of a binary tree is DEBFC. Find out the pre order traversal

ABDECF

The post order traversal of a binary tree is DEBFCA. Find out the pre order traversal

ABDECF

The reason for using pointer is ...

Accessing arrays or string elements

The reason for using pointer is ... Choose the false option from the following sentences

Accessing arrays or string elements

What is writen to the screen for the input "GoodA***fter****Noo**n"?

Adoretfoo

Pushdown list means:

All

A connected graph T without any cycles is called

All of above

The difference between linear array and a record is

All of above

Which of the following data structure is linear type?

All of above

ushdown list means:

All of the above

Which of the following data structure is linear type?

All off string,list,queue

Which of the following is the feature of stack?

All operations are at one end

In an array queue, data is stored in an _____ element.

Array

Which of the following data structure can't store the non-homogeneous data elements?

Arrays

Which of the following data structure is linear data structure?

Arrays

In the linked list implementation of the stack class, where does the push method place the new entry on the linked list?

At the head

In the linked list implementation of the queue class, where does the insert method place the new entry on the linked list?

At the tail

What of the following applications may use a stack?

Auxiliary data structure for algorithms.

Which of the following applications may use a stack?

Auxiliary data structure for algorithms.

The in order traversal of tree will yield a sorted listing of elements of tree in

Binary search trees

The size of a structure can be determined by a. size of variable name b. size of (struct tag)

Both a and b

select the most correct statement about the complexity of heapsort

Both best and worst cases are (nlogn)

Select the most correct statement about the complexity of selection sort

Both best and worst cases are 0(n^2)

Select the most correct statement about the complexity of selection sort

Both best and worst cases are O(n^2)

Select the most correct statement about the complexity of heapsort

Both best and worst cases are O(nlogn)

Sorting algorithm can be characterized as

Both of the above

The five items: A, B, C, D and E are pushed in a stack,one after the other starting from A. The stack is popped four times and each element is inserted in a queue. Then two elements are deleted from the queue and pushed back on the stack. Now one item is popped from the stack.

D

If the characters 'D', 'C', 'B', 'A' are placed in a queue (in that order), and then removed one at a time, in what order will they be removed?

DCBA

How can you fix a broken sequence? What is created?

Delete enough items so that the Fron arrow wraps around. This creates a single contiguous sequence.

A data structure where elements can be added or removed at either end but not in the middle

Deque

The depth of a complete binary tree is given by

Dn = log2n + 1

The depth of a complete binary tree is given by

Dn = log2n+1

The depth of a complete binary tree is given by

Dn=log2n+1

is rearranging pairs of elements which are out of order, until no such pairs remain.

Exchange

A binary tree whose every node has either zero or two children is called

Extended binary tree

When inorder traversing a tree resulted E A C K F H D B G; the preorder traversal would return

FAEKCDHGB

The Order followed by stack data structure is

FIFO

_______ form of access is used to add and remove nodes from a queue

FIFO , First In First Out

form of access is used to add and remove nodes from a queue

FIFO , First In First Out

Which of the following name does not relate to stacks?

FIFO lists

pointers store the next data element of a list

False

The search time is O(lgn) in the worst case , In 20-element skip lists, the node in position 3 points to the

False about skip list

In the linked-list version of the Queue class, which operations require linear time for their worst-case behavior?

False=(getFront, isEmpty, insert )

In the circular array version of the Queue class, which operations require linear time for their worst-case behavior?

False=(getFront, isEmpty, insert when the capacity has not yet been reached)

In the array version of the Stack class, which operations require linear time for their worst-case behavior?

False=(is_empty,peek,pop,push when the stack is below capacity)

In the linked-list version of the Stack class, which operations require linear time for their worst-case behavior?

False=(is_empty,peek,pop,push)

Which of the following statements about finding the shortest path are true:

For label-correcting method, information of any ,The complexity of Dijkstras algorithm is O(|V|2)

Specify the correct statement about a binary search tree(select the most suitable one).

In a binary search tree, all...than A.

singly linked list

In a every element contains some data and a link to the next element, which allows to keep the structure

Select the most correct statement:

In a linked list, the tail node is introduced for performance purpose only

What is the difference between a stack and a queue?

In a queue the first item inserted is the first to be removed (FIFO). In a stack the last item inserted is the first to be removed (LIFO)

Specify the correct statement about chaining method for handling collision

In chaining ... keys or references to keys.

Specify the correct statement about chaining method for handling collision

In chaining, only some ... keys or references to keys.

Which of the following is true about linked list implementation of stack?

In push operation = False.

Identify the data structure which allows deletions at both ends of the list but insertion at only one en

Input-restricted deque

Identify the data structure which allows deletions at both ends of the list but insertion at only one end.

Input-restricted deque

is putting an element in the appropriate place in a sorted list yields a larger sorted order list.

Insertion

sorting algorithm is frequently used when n is small where n is total number of elements.

Insertion

How is "peek" different in a queue?

It "peeks" at the value of the item at the front of the queue without removing it as opposed to the last value in a stack.

What is "peek"?

It allows the user to read the value at the top of the stack with out removing it.

Suppose we are considering a singly linked list and p is some node in the list which has both predecessor and successor nodes. What does the java code snippet below do? Node f=head; while(f.next!=p) f=f.next; f.next=p.next;

It deletes the node p

Where does the term queue come from?

It is a British reference to waiting in line. Fist in, first out.

The worst case occur in linear search algorithm when

Item is the last element in the array or item is not there at all

Which of the following applications may use a stack?

Keeping track & A parentheses & Syntax analyzer for a compiler.

Which of the following applications may use a stack?

Keeping track of previous choices(as in backtracking).

______ form of access is used to add and remove nodes from a stack

LIFO

form of access is used to add and remove nodes from a stack

LIFO

The memory address of fifth element of an array can be calculated by the formula

LOC(Array[5]=Base(Array)+w(5-lower bound), where w is the number of words per memory cell for array

Which of the following data structure is non-linear type?

(Strings, Lists, Stacks)= False.

The complexity of heap sort is

0(nlog n)

the complexity of merge sort is

0(nlog2n)

Given a weighted graph below. What is the total edge-weight of the minimum spanning tree of G?

27

How many parts are there in a declaration statement?

3

Given the division hash function h(x) = x%M, where M = 10 and Collision Resolution is linear probing. How the hash table looks like after inserting the following keys sequentially? 95,33,221,204,53,243

4

What is the breadth-first traversal of a tree below after deleting the node 2 by copying?

5 1 7 4 6 8 3

Suppose a singly linked list of integers is given below: (head)7 10 6 4 2 13 8 3(tail)

7 10 6 4 2 13 8 5 3

What is a deque?

A double-ended queue. You can insert items and either end & delete items from either end.

What is writen to the screen for the input"H*owAre***You**To****Day"?

HowAreYouT

Which graph representation is best?

It depends on the problem

What kind of list is best to answer questions such as "What is the item at position n?"

Lists implemented with an array.

Which of the following keywords are access modifier:

Protected, Private

Which data structure allows deleting data elements from front and inserting at rear?

Queues

Which of the following sorting algorithm is of divide-and-conquer type?

Quick sort

Subclasses or derived classes inherit the fields... , An abstract datatype can be part of a program in the form of an interface.

True

The keyword implements is used to specify that a class inherits from aninterface.

True

The recursive version increases program readability, improves self-documentation and simplifies coding

True

The node which is deleted from the list will ... e garbage collection, Deleting a node at the end of...ant time O(1), Processing for adding a node tothe end of list includes six steps

True about Doubly linked list

The size of a structure can be determined by a. size of variable name b. size of (struct tag)

both a and b

The elements of an array are stored successively in memory cells because

by this way computer can keep track only the address of the first element and the addresses of elements can be calculated

Suppose cursor refers to a node in a linked list (using the IntNode class with instance variables called data and link). What statement changes cursor so that it refers to the next node?

cursor = cursor.link;

Explain how you would create an algorithm that matches delimiters on the stack. Include errors in your explanation.

1. Read the characters from a string one at a time.

What is the correct definition of a hash function?

dai nhat

Suppose we have an array implementation of the stack class, with ten items in the stack stored at data[0] through data[9]. The CAPACITY is 42. Where does the push method place the new entry in the array?

data[10]

To delete a dynamically allocated array named `a`, the correct statement is

delete a

A graph that has neither self-loops nor parallel edges are called____

simple graph

a graph that has neither self-loop nor parallel edges are called

simple graph

Fill in the blank of the statement to form the most correct one: In a every element contains some data and a link to the next element which allows to keep the structure.

singly linked list

select the most correct statement

sort is 0(n^2), best case it is O(n)

The term "push" and "pop" is related to the

stacks

What is written to the screen for the input "carpets"?

steprac

which of the following applications may use a stack

store a waiting list undo sequence in the text editor

If every node u in G is adjacent to every other node v in G, a graph is said to be

strongly connected

if every node in G is adjiacent to every other node v in G, a graph said to be

strongly connected

In a graph if e=(u, v) means

u is processor and v is successor

Specify the correct implementation of in-order traverse algorithm for binary trees

void inOrder(Node p) {if(p != null){ inOrder(p.left); visit(p); inOrder(p.right); } }

push() method of the stack

void push(Integer x) {Node p = new Node(x); p.next=head; head=p; }

The Average case occurs in linear search algorithm

when item is somewhere in the middle of the array

Suppose the h(n) function is defined on the set of integer numbers as below. For the call h(3).how many calls to h will be made, including the original call? int h(int n) {if(n==0

| n==1) return(1); else return(h(n-1)+h(n-2)); } | 3

What is the minimum number of nodes in a full binary tree with height 3? find a tree the height of root is 1. and in a full binary tree every node other than tle leaves has two children).

7

What is the minimum number of nodes in a full binary tree with height 4?

7

What is value of the Boundary Folding Hash Function if K = 42-58-67 and TSize = 100?

94

what is the value of the Boundary Folding Hash Function if K = 42-58-67 and Tsize = 100

94

what is the value of the Shift Folding Hash Function if K = 42-58-67 and Tsize = 100

94

what is the value of the Shift Folding Hash Function if K = 45-65-79-8 and Tsize = 100

97

Select the statement that is most correct

A recursive method is a method that invokes itself directly or indirectly. For a recursive method to terminate there must be one or more base cases

ch = top element of the stack S if ch is isolated then remove it from the stack and put it to E else select the first vetex Y (by alphabet order). which is adjacent to ch.push Y to S and remove the edge (ch.Y) from the graph

B, D, C, B, A, B

In a graph if e=(u, v) means

B.e begins at u and ends at v C. u is processor and v is successor

Consider the implementation of the Stack using a partially-filled array. What goes wrong if we try to store the top of the Stack at location [0] and the bottom of the Stack at the last used position of the array?

Both push and pop would require linear time.

____will visit nodes of a tree starting from the highest (or lowest) level and moving down (or up) level by level and at a level, it visits nodes from left to right(or from right to left).

Breath-First Traversal

The five items: A, B, C, D and E are pushed in a stack,one after the other starting from A. The stack is popped four times and each element is inserted in a queue. Then two elements are deleted from the queue and pushed back on the stack. Now one item is popped from the stack.The popped item is.

D

Given a graph below. What is the output of depth-first traversal from vertex D? (visit nodes in ABC order if there are some nodes having the same selection ability).

D, C, B, A, E, G, F, H

Give a graph below. What is the output of breadth-first traversal from vetex D?(visit nodes in ABC order if there are some nodes having the same selection ability).

D, C, F, B, G, A, E, H

Depth-first traversal can not be implemented if ,A recursive implementation of preorder tree trav,There are six possible ordered depth-first traversal

False

In all cases, nonrecursive implementation is faster recursive implementation

False

In the array implementation, dequeuing can be executed in O(n)

False

In the array list, poping is executed in O(lgn) to the worst case

False

Given a weighted graph below and you are using the Dijkstra algorithm to find the sortest path from the vertex H to the vertex T. What are the correct order of vertices selected into the set S until the vertex T is selected?(Each step a vertex with minimal current distance is selected into S).

H, A, B, D, T

what is the correct definition of a hash function?

Hash function h(x) transform a particular key x, etc into an index i=h(x) in the table

The complexity of Binary search algorithm is

O(log n)

The complexity of merge sort algorithm is

O(n log n)

The complexity of merge sort algorithm is a.

O(n log n)

Basically, the complexity of inserting new element before a given node in the middle of a singly linked lists is

O(n)

Given a search() method in a binary search tree: Node search(int x) { Node p = root; while(p!=null && p.info != x){if(p<p.info) p = p.left; else p=p.right;} return(p);} The complexity of this algorithm is:

O(n)

New nodes are added to the of the queue.

back

select the most correct statement about the complexity of selection sort

both best and worst 0(n^2)

Which call will result in the most recursive calls?

fun(-1012);

Two dimensional arrays are also called

matrix arrays

What is written to the screen for the input "Good**Mor*ni***ngSir"?

risgnMog

What is the breadth-first traversal of a tree below after deleting the node 15 by merging?

30 5 40 10 35 25 20

Consider the AVL tree below. What is the breadth first traversal of the tree after inserting a node with value 24?

35, 22, 39, 12, 32, 37, 27, 24,

Give a raw message ' BBBYYYYBBBYYBBBBBYY'(without single quote).Run the run-length encoding algorithm for that message .what is the output?

3B4Y3B2Y5B2Y

Suppose T is a binary tree with 14 nodes. What is the minimum possible height of T?

4

Suppose T is a binary tree with 14 nodes. What is the minimum possible height of T? (Note: In a tree the height of root is 1)

4

T is a binary tree with 14 nodes. what is the minimum possiple height of T

4

a binary tree with 14 nodes. the minimum possible height of T

4

suppose T is a binary tree with 14 nodes. what is the minimum possible height of T

4

What is the breadth-first traversal of a tree below after deleting the node 5 by copying?

4 2 7 1 3 6 8

Given a raw message 'FFFF0000FFF00FFFFF00' (without single quote). Run the run-length encoding algorithm for that message, what is the output?

4F403F205F20

FFFFOOOOFFFOOFFFFFOO

4F4O3F2O5F2O

Give a raw message 'FFFFOOOOFFFOOFFFFFOO'(without single quote).Run the run-length encoding algorithm for that message .what is the output?

4F4O3F2O5F2O

What is the minimum number of nodes in a nearly complete binary tree with heigh 4?

7

what is the minimum number of nodes in a full binary tree with height 3

7

7 1 6 4 3 9 8 2

7 1 6 4 3 8 2

Suppose a doubly linked list of integers is given below and p is a reference to the node with value 3 in the list(i.e. p.info=3): (head)7 1 6 4 3 9 8 2(tail) What does the list look like after the following java code sippet is run?

7 1 6 4 3 8 2

7 10 6 4 2 13 8 3

7 10 6 4 2 13 8 5 3

7 11 6 14 3 9 8 12

7 11 6 14 5 3 9 8 12

Suppose a singly linked list of integers is given below and p is a reference to the node with value 3 in the list(i.e. p.info=3): (head)7 11 6 14 3 9 8 12(tail) What does the list look like after the following java code snippet is run?

7 11 6 14 5 3 9 8 12

Suppose a singly linked list of integers is given below. (head) 7 11 6 4 3 12 8 2 (tail) What does the list look like after the following java code snippet is run?

7 11 6 4 3 12 8 5 2

Suppose a singly linked list of integers is given below and p is a reference to the node with value 9 in the list (i.e. p.info=9): (head) 7 11 6 4 3 9 8 21 (tail)

7 11 6 4 3 13 9 8 21

7 11 6 4 3 15 8 12

7 11 6 4 3 35 15 8 12

Suppose the f(n) function is defined on the set of integer numbers as below. What is the value of f(-5)?

3

int fun(int n) {if(n < 0) return(fun(-n)); else if(n<5) return(2); else return(n*fun(n/2)); } What is the value of fun(5) ?

10

Given the character frequencies B : 32% C : 28% D : 16% E : 6% F : 18% Using Huffman encoding, what is the code for character D?(Suppose that when constructing a sub tree from 2 nodes we always place node with higher frequency on the left, and the left branch of a node gets value 0, the right one gets value 1)

100

Given the character frequencies B : 32% C : 28% D : 16% E : 6% F : 18% Using Huffman encoding, what is the code for character E?(Suppose that when constructing a sub tree from 2 nodes we always place node with higher frequency on the left, and the left branch of a node gets value 0, the right one gets value 1)

101

int fun(int n) {if(n<0) return(fun(-n)); else if(n<5) return(2); else return(n*fun(n-2)); } What is the value of fun(6)?

12

Consider the list of eight integers (n-8) below: 15, 13, 18, 19, 17, 12, 16, 14 What is the list after it is partitioned with low = 0 and up = n-1?

12, 13, 14, 15, 17, 19, 16, 18

What is the breadth-first traversal of a tree below after deleting the node 5 by merging?

2.1.4. 3. 7. 6. 8

27 11 6 4 3 10 8 2

27 11 6 4 3 10 19 8 2

Suppose a doubly linked list of integers is given below and p is a reference to the node with value 10 in the list(i.e. p.info=10): (head) 27 11 6 4 3 10 8 2(tail) What does the list look like after the following java code sippet is run?

27 11 6 4 3 10 19 8 2

What does the list look like after the following java code snippet is run? intx = 19;

27 11 6 4 3 10 19 8 2

Consider the following function: void quiz(int n) {if (n > 1) {quiz(n / 2); quiz(n / 2); } System.out.print("* "); } How many asterisks are printed by the function call quiz(5)?

3

Consider the usual algorithm for determining whether a sequence of parentheses is balanced. What is the maximum number of parentheses that will appear on the stack AT ANY ONE TIME when the algorithm analyzes: (()(())(()))?

3

Given the division hash function h(x) = x%M, where M = 10 and Collision Resolution is quadratic probing. i.e. when inserting a key x, the collision is resolved by finding an available position at (h(x) + i^2)%M), i=1, 2, ... How the hash table looks like after inserting the following keys sequentially?

3


Set pelajaran terkait

Unit 8 Environmental Science: Climate

View Set

Chromatin structure and organization

View Set

Community Health Nursing Chapter 1

View Set

DNA, Hot Pockets, & The Longest Word Ever: Crash Course Biology #11

View Set

Career Development + Job Seeking Skills

View Set

KNES 315 - CH 7 - Injury Assessment

View Set

FIN 302 QUIZ 1 PRAC Q'S (from chap 1 + 3)

View Set

Competitive Advantage, Firm Performance, & Business Models

View Set

Concepts of Dynamics of Management

View Set

Life Insurance - Chapter 2 - Types of Life Policies

View Set

Chapter 03 Quiz-General Biology I

View Set