Category: Data Structure

Data Structure

Given a singly linked list find the n-th node from the back. 0

Given a singly linked list find the n-th node from the back.

Solution 1: Reverse the linked list and select the n-th node from the head of the linked list. Solution 2: Maintain 2 pointers n nodes apart. When the 1st pointer reaches the tail, the...

What are the advantages and disadvantages of B-star trees over Binary trees? 0

What are the advantages and disadvantages of B-star trees over Binary trees?

B-star trees have better data structure and are faster in search than Binary trees, but it’s harder to write codes for B-start trees.

Why is the isEmpty() member method called? 0

Why is the isEmpty() member method called?

The isEmpty() member method is called within the dequeue process to determine if there is an item in the queue to be removed i.e. isEmpty() is called to decide whether the queue has at...

What is the relationship between a queue and its underlying array? 0

What is the relationship between a queue and its underlying array?

Data stored in a queue is actually stored in an array. Two indexes, front and end will be used to identify the start and end of the queue. When an element is removed front...

What is a queue in data structure? 0

What is a queue in data structure?

A Queue is a sequential organization of data in data structure. A queue is a first in first out type of data structure. An element is inserted at the last position and an element...

What does isEmpty() member method determines? 0

What does isEmpty() member method determines?

isEmpty() checks if the stack has at least one element. This method is called by Pop() before retrieving and returning the top element.

What method removes the value from the top of a stack? 0

What method removes the value from the top of a stack?

The pop() member method removes the value from the top of a stack, which is then returned by the pop() member method to the statement that calls the pop() member method.

What method is used to place a value onto the top of a stack? 0

What method is used to place a value onto the top of a stack?

It is push() method. Push is the direction that data is being added to the stack. push() member method places a value onto the top of a stack.

What is significance of an asterisk (*) ? 0

What is significance of an asterisk (*) ?

The symbol asterisk (*) tells the computer that you are declaring a pointer. Actually it depends on context. – In a statement like int *ptr; the ‘*’ tells that you are declaring a pointer....