Data Structure


Difference between calloc and malloc ?

malloc: allocate n bytes
calloc: allocate m times n bytes initialized to 0

By on September 21, 2010 | Data Structure

What are the major data structures used in the following areas : RDBMS, Network data model & Hierarchical data model.

1. RDBMS Array (i.e. Array of structures)
2. Network data model Graph
3. Hierarchical data model Trees.

By on | Data Structure

Which file contains the definition of member functions?

Definitions of member functions for the Linked List class are contained in the LinkedList.cpp file.

By on | Data Structure

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

The appendNode() member function places a new node at the end of the linked list. The appendNode() requires an integer representing the current data of the node.

By on | Data Structure

What is Linked List ?

Linked List is one of the fundamental data structures. It consists of a sequence of? nodes, each containing arbitrary data fields and one or two (”links”) pointing to the next and/or previous nodes. A linked list is a self-referential datatype because it contains a pointer or link to another data of the same type. Linked lists permit insertion and removal of nodes at any point in the list in constant time, but do not allow random access.

By on | Data Structure

What does each entry in the Link List called?

Each entry in a linked list is called a node. Think of a node as an entry that has three sub entries. One sub entry contains the data, which may be one attribute or many attributes. Another points to the previous node, and the last points to the next node. When you enter a new item on a linked list, you allocate the new node and then set the pointers to previous and next nodes.

By on | Data Structure

How is the front of the queue calculated ?

The front of the queue is calculated by front = (front+1) % size.

By on | Data Structure

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 least one element. This method is called by the dequeue() method before returning the front element.

By on | Data Structure

Which process places data at the back of the queue?

Enqueue is the process that places data at the back of the queue.

By on | Data Structure

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 will be incremented by 1. In case it reaches past the last index available it will be reset to 0. Then it will be checked with end. If it is greater than end queue is empty.

When an element is added end will be incremented by 1. In case it reaches past the last index available it will be reset to 0. After incrementing it will be checked with front. If they are equal queue is full.

By on | Data Structure

Copy Protected by Send free sms - Love2sms.