# Category Archives: Data Structures

## Array Representation Of Binary Heap

A Binary Heap is a Complete Binary Tree. A binary heap is typically represented as array. The representation is done as: The root element will be at Arr[0]. Below table shows indexes of other nodes for the ith node, i.e., Arr[i]: Arr[i/2] Returns the parent node Arr[(2*i)+1] Returns the left child node Arr[(2*i)+2] Returns the… Read More »

See Placement Course for placement preparation, GATE Corner for GATE CS Preparation and Quiz Corner for all Quizzes on GeeksQuiz.

## Delete last occurrence of an item from linked list

Given a liked list and a key to be deleted. Delete last occurrence of key from linked. The list may have duplicates. Examples: Input: 1->2->3->5->2->10, key = 2 Output: 1->2->3->5->10 We strongly recommend you to minimize your browser and try this yourself first The idea is to traverse the linked list from beginning to end.… Read More »

See Placement Course for placement preparation, GATE Corner for GATE CS Preparation and Quiz Corner for all Quizzes on GeeksQuiz.

In Java, LinkedList class implements the list interface. This class consists of the following methods : 1. boolean add(Object element) : It appends the element to the end of the list. 2. void add(int index, Object element): It inserts the element at the position ‘index’ in the list. 3. void addFirst(Object element) : It inserts… Read More »

See Placement Course for placement preparation, GATE Corner for GATE CS Preparation and Quiz Corner for all Quizzes on GeeksQuiz.

## Stack Class in Java

Java provides an inbuilt object type called Stack. It is a collection that is based on the last in first out (LIFO) principle. On Creation, a stack is empty. It extends Vector class with five methods that allow a vector to be treated as a stack. The five methods are: 1. Object push(Object element) :… Read More »

See Placement Course for placement preparation, GATE Corner for GATE CS Preparation and Quiz Corner for all Quizzes on GeeksQuiz.

## Enumeration of Binary Trees

A Binary Tree is labeled if every node is assigned a label and a Binary Tree is unlabeled if nodes are not assigned any label. Below two are considered same unlabeled trees o o / \ / \ o o o o Below two are considered different labeled trees A C / \ / \… Read More »

See Placement Course for placement preparation, GATE Corner for GATE CS Preparation and Quiz Corner for all Quizzes on GeeksQuiz.

## Delete a Linked List node at a given position

Given a singly linked list and a position, delete a linked list node at the given position.

See Placement Course for placement preparation, GATE Corner for GATE CS Preparation and Quiz Corner for all Quizzes on GeeksQuiz.