# All posts tagged Data Structures

Linear Search Array in C Programming Here you will find program for linear search array in C Programming. Linear search is the simplest searching algorithm which is sometimes known as sequential search. #include <stdio.h> #define MAX 5 /** function : linearSearch() to search an element. **/ int linearSearch(int *a,int n) . . . Read more

Bubble Sort Data Structure Example in C C program for bubble sort: c programming code for bubble sort to sort numbers or arrange them in ascending order. #include <stdio.h> #define MAX 100 int main() { int arr[MAX],limit; int i,j,temp; printf(“Enter total number of elements: “); scanf(“%d”,&limit); /*Read array*/ printf(“Enter array . . . Read more

Java Program to Find LCA of u and v by reducing problem to RMQ This section covers Data Structure programming example for Java program to find LCA of u and v by reducing problem to RMQ. import java.util.*; // A binary tree node class Node { Node left, right; int . . . Read more

C++ Program for Range Minimum Query using Segment Tree A segment tree is a heap-like data structure that can be used for solving Range Minimum/Maximum Query Problems. #include <stdio.h> #include <math.h> #include <limits.h> // A utility function to get minimum of two numbers int minVal(int x, int y) { return (x < . . . Read more

C++ Program to Demonstrate Operations of KD Tree C++ program to demonstrate operations of KD tree – Data Structure programming example of C++ program to demonstrate operations of KD tree. #include<bits/stdc++.h> using namespace std; const int k = 2; // A structure to represent node of kd tree struct Node . . . Read more

Java Program to Construct an Expression Tree Java program to construct an expression tree- This is Data Structure Programming Example for Java program to construct an expression tree. import java.util.Stack; // Java program for expression tree class Node { char value; Node left, right; Node(char item) { value = item; . . . Read more

C++ Program to Demonstrate Operations of Binary Index Tree A BIT (Binary Indexed Tree) or Fenwick Tree is a data structure providing efficient methods for calculation. #include <iostream> using namespace std; /* n –> No. of elements present in input array. BITree[0..n] –> Array that represents Binary Indexed Tree. arr[0..n-1] . . . Read more

C++ program to implement Cartesian Tree sort Data Structure – This section covers Simple Data Structure Programming Example of C++ program to implement Cartesian Tree sort. #include<bits/stdc++.h> using namespace std; struct Node { int data; Node *left, *right; }; typedef pair<int, Node*> iNPair; void pQBasedTraversal(Node* root) { priority_queue <iNPair, vector<iNPair>, . . . Read more

C program to Demonstrate Ternary Search Tree Dtat Structure -This is C program to Demonstrate Ternary Search Tree to insert, travese and search operations in Data Structure & Algorithm. #include <stdio.h> #include <stdlib.h> #define MAX 50 // A node of ternary search tree struct Node { char data; // True . . . Read more

Java Program to Implement Max Heap This Java program is to implement Min heap. A Heap data structure is a Tree based data structure that satisfies the HEAP Property “If A is a parent node of B then key(A) is ordered with respect to key(B) with the same ordering applying . . . Read more