Program to Convert Octal to Hexadecimal
Last Updated :
12 Jul, 2025
Given an Octal number, the task is to convert it into a Hexadecimal number.
Examples:
Input: 47
Output: 27
Explanation:
Decimal value of 47 is = (7 * 1) + (4 * 8) = 39
Now, convert this number to hexadecimal
39/16 -> quotient = 2, remainder = 7
2/16 -> quotient = 0, remainder = 2
So, the equivalent hexadecimal number is = 27
Input: 235
Output: 9d
Approach:
An Octal Number or oct for short is the base-8 number and uses the digits 0 to 7. Octal numerals can be made from binary numerals by grouping consecutive binary digits into groups of three (starting from the right).
A Hexadecimal Number is a positional numeral system with a radix, or base, of 16 and uses sixteen distinct symbols. It may be a combination of alphabets and numbers. It uses numbers from 0 to 9 and alphabets A to F.
Steps of Conversion:
The simplest way is to convert the octal number into a decimal, then the decimal into hexadecimal form.
- Write the powers of 8 (1, 8, 64, 512, 4096, and so on) beside the octal digits from bottom to top.
- Multiply each digit by its power.
- Add up the answers. This is the decimal solution.
- Divide the decimal number by 16.
- Get the integer quotient for the next iteration (if the number will not divide equally by 16, then round down the result to the nearest whole number).
- Keep a note of the remainder, it should be between 0 and 15.
- Repeat the steps from step 4. until the quotient is equal to 0.
- Write out all the remainders, from bottom to top.
- Convert any remainders bigger than 9 into hex letters. This is the hex solution.
For example, if the given octal number is 5123:
Then the decimal number (2560 + 64 + 16 + 3) is: 2643
|
2643/16 | 165 | 3 |
165/16 | 10 | 5 |
10/16 | 0 | 10 (a) |
Finally, the hexadecimal number is: a53
Below is the implementation of the above approach:
C++
// C++ program to convert Octal
// to Hexadecimal
#include<bits/stdc++.h>
using namespace std;
// Function to convert octal to decimal
int octalToDecimal(int n)
{
int num = n;
int dec_value = 0;
// Initializing base value
// to 1, i.e 8^0
int base = 1;
int temp = num;
while (temp)
{
// Extracting last digit
int last_digit = temp % 10;
temp = temp / 10;
// Multiplying last digit with
// appropriate base value and
// adding it to dec_value
dec_value += last_digit * base;
base = base * 8;
}
return dec_value;
}
// Function to convert decimal
// to hexadecimal
string decToHexa(int n)
{
// char array to store
// hexadecimal number
char hexaDeciNum[100];
// counter for hexadecimal
// number array
int i = 0;
while(n != 0)
{
// Temporary variable to
// store remainder
int temp = 0;
// Storing remainder in
// temp variable.
temp = n % 16;
// Check if temp < 10
if (temp < 10)
{
hexaDeciNum[i] = temp + 48;
i++;
}
else
{
hexaDeciNum[i] = temp + 87;
i++;
}
n = n / 16;
}
string ans = "";
// Printing hexadecimal number array
// in reverse order
for(int j = i - 1; j >= 0; j--)
{
ans += hexaDeciNum[j];
}
return ans;
}
// Driver Code
int main()
{
string hexnum;
int decnum, octnum;
// Taking 5123 as an example of
// Octal Number.
octnum = 5123;
// Convert Octal to Decimal
decnum = octalToDecimal(octnum);
// Convert Decimal to Hexadecimal
hexnum = decToHexa(decnum);
cout << "Equivalent Hexadecimal Value = "
<< hexnum << endl;
}
// This code is contributed by pratham76
Java
// Java Program to Convert Octal
// to Hexadecimal
import java.util.Scanner;
public class JavaProgram {
public static void main(String args[])
{
String octnum, hexnum;
int decnum;
Scanner scan = new Scanner(System.in);
// Taking 5123 as an example of
// Octal Number.
octnum = "5123";
// Convert Octal to Decimal
decnum = Integer.parseInt(octnum, 8);
// Convert Decimal to Hexadecimal
hexnum = Integer.toHexString(decnum);
System.out.print("Equivalent Hexadecimal Value = "
+ hexnum);
}
}
Python3
# Python3 program to convert octal
# to hexadecimal
# Taking 5123 as an example of
# octal number
octnum = "5123"
# Convert octal to decimal
decnum = int(octnum, 8)
# Convert decimal to hexadecimal
hexadecimal = hex(decnum).replace("0x", "")
# Printing the hexadecimal value
print("Equivalent Hexadecimal Value =", hexadecimal)
# This code is contributed by virusbuddah_
C#
// C# Program to Convert Octal
// to Hexadecimal
using System;
class GFG{
// Function to convert octal
// to decimal
static int octalToDecimal(int n)
{
int num = n;
int dec_value = 0;
// Initializing base value
// to 1, i.e 8^0
int b_ase = 1;
int temp = num;
while (temp > 0)
{
// Extracting last digit
int last_digit = temp % 10;
temp = temp / 10;
// Multiplying last digit
// with appropriate base
// value and adding it to
// dec_value
dec_value += last_digit * b_ase;
b_ase = b_ase * 8;
}
return dec_value;
}
// Function to convert decimal
// to hexadecimal
static string decToHexa(int n)
{
// char array to store
// hexadecimal number
char []hexaDeciNum = new char[100];
// counter for hexadecimal
// number array
int i = 0;
string ans = "";
while(n != 0)
{
// temporary variable to
// store remainder
int temp = 0;
// storing remainder
// in temp variable.
temp = n % 16;
// check if temp < 10
if(temp < 10)
{
hexaDeciNum[i] = (char)(temp + 48);
i++;
}
else
{
hexaDeciNum[i] = (char)(temp + 87);
i++;
}
n = n / 16;
}
for(int j = i - 1; j >= 0; j--)
{
ans += hexaDeciNum[j];
}
return ans;
}
// Driver code
public static void Main(string []args)
{
string octnum, hexnum;
int decnum;
// Taking 5123 as an
// example of Octal Number.
octnum = "5123";
// Convert Octal to Decimal
decnum = octalToDecimal(Int32.Parse(octnum));
// Convert Decimal to Hexadecimal
hexnum = decToHexa(decnum);
Console.Write("Equivalent Hexadecimal Value = " +
hexnum);
}
}
// This code is contributed by rutvik_56
JavaScript
// JavaScript program to convert Octal
// to Hexadecimal
// Function to convert octal to decimal
function octalToDecimal( n)
{
var num = n;
var dec_value = 0;
// Initializing base value
// to 1, i.e 8^0
var base = 1;
var temp = num;
while (temp > 0)
{
// Extracting last digit
var last_digit = temp % 10;
temp = Math.floor(temp / 10);
// Multiplying last digit with
// appropriate base value and
// adding it to dec_value
dec_value += last_digit * base;
base = base * 8;
}
return dec_value;
}
// Function to convert decimal
// to hexadecimal
function decToHexa( n)
{
// char array to store
// hexadecimal number
var hexaDeciNum = new Array(100);
// counter for hexadecimal
// number array
var i = 0;
while(n != 0)
{
// Temporary variable to
// store remainder
var temp = 0;
// Storing remainder in
// temp variable.
temp = n % 16;
// Check if temp < 10
if (temp < 10)
{
hexaDeciNum[i] = temp + 48;
i++;
}
else
{
hexaDeciNum[i] = temp + 87;
i++;
}
n = Math.floor(n / 16);
}
var ans = "";
// Printing hexadecimal number array
// in reverse order
for(var j = i - 1; j >= 0; j--)
{
ans += String.fromCharCode(hexaDeciNum[j]);
}
return ans;
}
// Driver Code
var hexnum;
var decnum, octnum;
// Taking 5123 as an example of
// Octal Number.
octnum = 5123;
// Convert Octal to Decimal
decnum = octalToDecimal(octnum);
// Convert Decimal to Hexadecimal
hexnum = decToHexa(decnum);
console.log("Equivalent Hexadecimal Value = " + hexnum);
// This code is contributed by phasing17
OutputEquivalent Hexadecimal Value = a53
Time Complexity: O(logN),The time complexity of this algorithm is O(logN), where N is the octal number. This is because we use a loop which iterates through the octal number and performs some operations on each iteration.
Space Complexity: O(N),The space complexity of this algorithm is O(N), where N is the octal number. This is because we use an array to store the hexadecimal number and this array can have up to N elements.
Optimized Approach:
There are a few minor improvements that can be made:
- Avoid using char array to store hexadecimal digits: Instead of using a character array to store the hexadecimal digits, we can directly concatenate the hexadecimal digits to a string. This would make the code simpler and avoid the need for reversing the character array.
- Combine octal to decimal and decimal to hexadecimal conversion functions: Since we need to convert octal to decimal and then decimal to hexadecimal, we can combine these two functions into a single function to avoid unnecessary function calls and variable assignments.
Here's the optimized code:
C++
#include <iostream>
using namespace std;
// Function to convert octal to hexadecimal
string octalToHexadecimal(int n)
{
int decimal = 0, base = 1;
while (n > 0) {
int rem = n % 10;
decimal += rem * base;
n /= 10;
base *= 8;
}
string hexadecimal = "";
while (decimal > 0) {
int rem = decimal % 16;
if (rem < 10) {
hexadecimal = to_string(rem) + hexadecimal;
} else {
hexadecimal = (char)(rem - 10 + 'A') + hexadecimal;
}
decimal /= 16;
}
return hexadecimal;
}
// Driver code
int main()
{
int octal = 5123;
string hexadecimal = octalToHexadecimal(octal);
cout << "Equivalent Hexadecimal Value = " << hexadecimal << endl;
return 0;
}
Java
import java.util.*;
public class Main {
// Function to convert octal to decimal
public static int octalToDecimal(int n) {
int num = n;
int dec_value = 0;
// Initializing base value to 1, i.e 8^0
int base = 1;
int temp = num;
while (temp != 0) {
// Extracting last digit
int last_digit = temp % 10;
temp /= 10;
// Multiplying last digit with appropriate base value and adding it to dec_value
dec_value += last_digit * base;
base *= 8;
}
return dec_value;
}
// Function to convert decimal to hexadecimal
public static String decToHexa(int n) {
// char array to store hexadecimal number
char[] hexaDeciNum = new char[100];
// counter for hexadecimal number array
int i = 0;
while (n != 0) {
// Temporary variable to store remainder
int temp = 0;
// Storing remainder in temp variable
temp = n % 16;
// Check if temp < 10
if (temp < 10) {
hexaDeciNum[i] = (char)(temp + 48);
i++;
} else {
hexaDeciNum[i] = (char)(temp + 55);
i++;
}
n /= 16;
}
String ans = "";
// Printing hexadecimal number array in reverse order
for (int j = i - 1; j >= 0; j--) {
ans += hexaDeciNum[j];
}
return ans;
}
// Driver Code
public static void main(String[] args) {
int octnum = 5123;
// Convert Octal to Decimal
int decnum = octalToDecimal(octnum);
// Convert Decimal to Hexadecimal
String hexnum = decToHexa(decnum);
System.out.println("Equivalent Hexadecimal Value = " + hexnum);
}
}
Python3
def octalToDecimal(n):
num = n
dec_value = 0
base = 1
temp = num
while temp:
last_digit = temp % 10
temp = temp // 10
dec_value += last_digit * base
base = base * 8
return dec_value
def decToHexa(n):
hexaDeciNum = ''
while n != 0:
temp = 0
temp = n % 16
if temp < 10:
hexaDeciNum = str(temp) + hexaDeciNum
else:
hexaDeciNum = chr(temp + 87) + hexaDeciNum
n = n // 16
return hexaDeciNum
# Driver code
if __name__ == '__main__':
octnum = 5123
decnum = octalToDecimal(octnum)
hexnum = decToHexa(decnum)
print("Equivalent Hexadecimal Value = {}".format(hexnum))
C#
using System;
namespace OctalToHexadecimal
{
class Program
{
// Function to convert octal to decimal
static int OctalToDecimal(int n)
{
int num = n;
int dec_value = 0;
int base_value = 1;
while (num != 0)
{
int last_digit = num % 10;
num = num / 10;
dec_value += last_digit * base_value;
base_value = base_value * 8;
}
return dec_value;
}
// Function to convert decimal to hexadecimal
static string DecimalToHexadecimal(int n)
{
char[] hexaDeciNum = new char[100];
int i = 0;
while (n != 0)
{
int temp = 0;
temp = n % 16;
if (temp < 10)
{
hexaDeciNum[i] = (char)(temp + 48);
i++;
}
else
{
hexaDeciNum[i] = (char)(temp + 55);
i++;
}
n = n / 16;
}
string hexadecimal = new string(hexaDeciNum, 0, i);
return hexadecimal;
}
// Main function
static void Main(string[] args)
{
int octalNum = 5123;
int decimalNum = OctalToDecimal(octalNum);
string hexadecimalNum = DecimalToHexadecimal(decimalNum);
Console.WriteLine("Equivalent Hexadecimal Value = " + hexadecimalNum);
}
}
}
JavaScript
// Function to convert octal to decimal
function octalToDecimal(n) {
let num = n;
let dec_value = 0;
let base = 1;
let temp = num;
while (temp) {
let last_digit = temp % 10;
temp = Math.floor(temp / 10);
dec_value += last_digit * base;
base *= 8;
}
return dec_value;
}
// Function to convert decimal to hexadecimal
function decToHexa(n) {
let hexaDeciNum = [];
let i = 0;
while (n != 0) {
let temp = 0;
temp = n % 16;
if (temp < 10) {
hexaDeciNum[i] = temp + 48;
} else {
hexaDeciNum[i] = temp + 87;
}
i++;
n = Math.floor(n / 16);
}
let ans = "";
for (let j = i - 1; j >= 0; j--) {
ans += String.fromCharCode(hexaDeciNum[j]);
}
return ans;
}
// Driver code
let octnum = 5123;
let decnum = octalToDecimal(octnum);
let hexnum = decToHexa(decnum);
console.log("Equivalent Hexadecimal Value = " + hexnum);
OutputEquivalent Hexadecimal Value = A53
Time Complexity: O(logN)
Auxiliary Space: O(N)
Method: Using Look-up table method
First, an unordered map is created to store the hexadecimal values for each possible remainder when dividing a decimal number by 16. The octal input number is then converted to its decimal representation using the usual method of multiplying each digit by its corresponding power of 8 and summing the results. Finally, the decimal number is converted to its hexadecimal representation by repeatedly dividing by 16 and looking up the corresponding hexadecimal digit from the lookup table.
C++
#include <iostream>
#include <string>
#include <unordered_map>
using namespace std;
// Function to convert octal to hexadecimal
string octalToHexadecimal(int n)
{
// Lookup table for hexadecimal values
unordered_map<int, char> hexLookupTable{
{0, '0'}, {1, '1'}, {2, '2'}, {3, '3'},
{4, '4'}, {5, '5'}, {6, '6'}, {7, '7'},
{8, '8'}, {9, '9'}, {10, 'A'}, {11, 'B'},
{12, 'C'}, {13, 'D'}, {14, 'E'}, {15, 'F'}
};
// Convert octal to decimal
int decimal = 0, base = 1;
while (n > 0) {
int rem = n % 10;
decimal += rem * base;
n /= 10;
base *= 8;
}
// Convert decimal to hexadecimal
string hexadecimal = "";
while (decimal > 0) {
int rem = decimal % 16;
hexadecimal = hexLookupTable[rem] + hexadecimal;
decimal /= 16;
}
return hexadecimal;
}
// Driver code
int main()
{
int octal = 5123;
string hexadecimal = octalToHexadecimal(octal);
cout << "Equivalent Hexadecimal Value = " << hexadecimal << endl;
return 0;
}
Java
import java.util.HashMap;
public class GFG {
// Function to convert octal to hexadecimal
public static String octalToHexadecimal(int n) {
// Lookup table for hexadecimal values
HashMap<Integer, Character> hexLookupTable = new HashMap<>();
hexLookupTable.put(0, '0');
hexLookupTable.put(1, '1');
hexLookupTable.put(2, '2');
hexLookupTable.put(3, '3');
hexLookupTable.put(4, '4');
hexLookupTable.put(5, '5');
hexLookupTable.put(6, '6');
hexLookupTable.put(7, '7');
hexLookupTable.put(8, '8');
hexLookupTable.put(9, '9');
hexLookupTable.put(10, 'A');
hexLookupTable.put(11, 'B');
hexLookupTable.put(12, 'C');
hexLookupTable.put(13, 'D');
hexLookupTable.put(14, 'E');
hexLookupTable.put(15, 'F');
// Convert octal to decimal
int decimal = 0, base = 1;
while (n > 0) {
int rem = n % 10;
decimal += rem * base;
n /= 10;
base *= 8;
}
// Convert decimal to hexadecimal
StringBuilder hexadecimal = new StringBuilder();
while (decimal > 0) {
int rem = decimal % 16;
hexadecimal.insert(0, hexLookupTable.get(rem));
decimal /= 16;
}
return hexadecimal.toString();
}
// Driver code
public static void main(String[] args) {
int octal = 5123;
String hexadecimal = octalToHexadecimal(octal);
System.out.println("Equivalent Hexadecimal Value = " + hexadecimal);
}
}
Python3
def octal_to_hexadecimal(n):
# Lookup table for hexadecimal values
hex_lookup_table = {
0: '0', 1: '1', 2: '2', 3: '3',
4: '4', 5: '5', 6: '6', 7: '7',
8: '8', 9: '9', 10: 'A', 11: 'B',
12: 'C', 13: 'D', 14: 'E', 15: 'F'
}
# Convert octal to decimal
decimal = 0
base = 1
while n > 0:
rem = n % 10
decimal += rem * base
n //= 10
base *= 8
# Convert decimal to hexadecimal
hexadecimal = ""
while decimal > 0:
rem = decimal % 16
hexadecimal = hex_lookup_table[rem] + hexadecimal
decimal //= 16
return hexadecimal
# Driver code
octal = 5123
hexadecimal = octal_to_hexadecimal(octal)
print("Equivalent Hexadecimal Value =", hexadecimal)
C#
using System;
using System.Collections.Generic;
public class GFG
{
// Function to convert octal to hexadecimal
public static string OctalToHexadecimal(int n)
{
// Lookup table for hexadecimal values
Dictionary<int, char> hexLookupTable = new Dictionary<int, char>()
{
{0, '0'}, {1, '1'}, {2, '2'}, {3, '3'},
{4, '4'}, {5, '5'}, {6, '6'}, {7, '7'},
{8, '8'}, {9, '9'}, {10, 'A'}, {11, 'B'},
{12, 'C'}, {13, 'D'}, {14, 'E'}, {15, 'F'}
};
// Convert octal to decimal
int decimalNum = 0, baseVal = 1;
while (n > 0)
{
int rem = n % 10;
decimalNum += rem * baseVal;
n /= 10;
baseVal *= 8;
}
// Convert decimal to hexadecimal
string hexadecimal = "";
while (decimalNum > 0)
{
int rem = decimalNum % 16;
hexadecimal = hexLookupTable[rem] + hexadecimal;
decimalNum /= 16;
}
return hexadecimal;
}
// Driver code
public static void Main(string[] args)
{
int octal = 5123;
string hexadecimal = OctalToHexadecimal(octal);
Console.WriteLine("Equivalent Hexadecimal Value = " + hexadecimal);
}
}
JavaScript
function OctalToHexadecimal(n) {
// Lookup table for hexadecimal values
const hexLookupTable = {
0: '0', 1: '1', 2: '2', 3: '3',
4: '4', 5: '5', 6: '6', 7: '7',
8: '8', 9: '9', 10: 'A', 11: 'B',
12: 'C', 13: 'D', 14: 'E', 15: 'F'
};
// Convert octal to decimal
let decimalNum = 0;
let baseVal = 1;
while (n > 0) {
let rem = n % 10;
decimalNum += rem * baseVal;
n = Math.floor(n / 10);
baseVal *= 8;
}
// Convert decimal to hexadecimal
let hexadecimal = "";
while (decimalNum > 0) {
let rem = decimalNum % 16;
hexadecimal = hexLookupTable[rem] + hexadecimal;
decimalNum = Math.floor(decimalNum / 16);
}
return hexadecimal;
}
// Driver code
const octal = 5123;
const hexadecimal = OctalToHexadecimal(octal);
console.log("Equivalent Hexadecimal Value = " + hexadecimal);
OutputEquivalent Hexadecimal Value = A53
The time complexity of the code is O(log n) since it involves converting the octal number to decimal and then to hexadecimal, both of which have a logarithmic time complexity.
The auxiliary space complexity is O(n) since only a small unordered map is created, which does not depend on the size of the input.
Similar Reads
Basics & Prerequisites
Data Structures
Array Data StructureIn this article, we introduce array, implementation in different popular languages, its basic operations and commonly seen problems / interview questions. An array stores items (in case of C/C++ and Java Primitive Arrays) or their references (in case of Python, JS, Java Non-Primitive) at contiguous
3 min read
String in Data StructureA string is a sequence of characters. The following facts make string an interesting data structure.Small set of elements. Unlike normal array, strings typically have smaller set of items. For example, lowercase English alphabet has only 26 characters. ASCII has only 256 characters.Strings are immut
2 min read
Hashing in Data StructureHashing is a technique used in data structures that efficiently stores and retrieves data in a way that allows for quick access. Hashing involves mapping data to a specific index in a hash table (an array of items) using a hash function. It enables fast retrieval of information based on its key. The
2 min read
Linked List Data StructureA linked list is a fundamental data structure in computer science. It mainly allows efficient insertion and deletion operations compared to arrays. Like arrays, it is also used to implement other data structures like stack, queue and deque. Hereâs the comparison of Linked List vs Arrays Linked List:
2 min read
Stack Data StructureA Stack is a linear data structure that follows a particular order in which the operations are performed. The order may be LIFO(Last In First Out) or FILO(First In Last Out). LIFO implies that the element that is inserted last, comes out first and FILO implies that the element that is inserted first
2 min read
Queue Data StructureA Queue Data Structure is a fundamental concept in computer science used for storing and managing data in a specific order. It follows the principle of "First in, First out" (FIFO), where the first element added to the queue is the first one to be removed. It is used as a buffer in computer systems
2 min read
Tree Data StructureTree Data Structure is a non-linear data structure in which a collection of elements known as nodes are connected to each other via edges such that there exists exactly one path between any two nodes. Types of TreeBinary Tree : Every node has at most two childrenTernary Tree : Every node has at most
4 min read
Graph Data StructureGraph Data Structure is a collection of nodes connected by edges. It's used to represent relationships between different entities. If you are looking for topic-wise list of problems on different topics like DFS, BFS, Topological Sort, Shortest Path, etc., please refer to Graph Algorithms. Basics of
3 min read
Trie Data StructureThe Trie data structure is a tree-like structure used for storing a dynamic set of strings. It allows for efficient retrieval and storage of keys, making it highly effective in handling large datasets. Trie supports operations such as insertion, search, deletion of keys, and prefix searches. In this
15+ min read
Algorithms
Searching AlgorithmsSearching algorithms are essential tools in computer science used to locate specific items within a collection of data. In this tutorial, we are mainly going to focus upon searching in an array. When we search an item in an array, there are two most common algorithms used based on the type of input
2 min read
Sorting AlgorithmsA Sorting Algorithm is used to rearrange a given array or list of elements in an order. For example, a given array [10, 20, 5, 2] becomes [2, 5, 10, 20] after sorting in increasing order and becomes [20, 10, 5, 2] after sorting in decreasing order. There exist different sorting algorithms for differ
3 min read
Introduction to RecursionThe process in which a function calls itself directly or indirectly is called recursion and the corresponding function is called a recursive function. A recursive algorithm takes one step toward solution and then recursively call itself to further move. The algorithm stops once we reach the solution
14 min read
Greedy AlgorithmsGreedy algorithms are a class of algorithms that make locally optimal choices at each step with the hope of finding a global optimum solution. At every step of the algorithm, we make a choice that looks the best at the moment. To make the choice, we sometimes sort the array so that we can always get
3 min read
Graph AlgorithmsGraph is a non-linear data structure like tree data structure. The limitation of tree is, it can only represent hierarchical data. For situations where nodes or vertices are randomly connected with each other other, we use Graph. Example situations where we use graph data structure are, a social net
3 min read
Dynamic Programming or DPDynamic Programming is an algorithmic technique with the following properties.It is mainly an optimization over plain recursion. Wherever we see a recursive solution that has repeated calls for the same inputs, we can optimize it using Dynamic Programming. The idea is to simply store the results of
3 min read
Bitwise AlgorithmsBitwise algorithms in Data Structures and Algorithms (DSA) involve manipulating individual bits of binary representations of numbers to perform operations efficiently. These algorithms utilize bitwise operators like AND, OR, XOR, NOT, Left Shift, and Right Shift.BasicsIntroduction to Bitwise Algorit
4 min read
Advanced
Segment TreeSegment Tree is a data structure that allows efficient querying and updating of intervals or segments of an array. It is particularly useful for problems involving range queries, such as finding the sum, minimum, maximum, or any other operation over a specific range of elements in an array. The tree
3 min read
Pattern SearchingPattern searching algorithms are essential tools in computer science and data processing. These algorithms are designed to efficiently find a particular pattern within a larger set of data. Patten SearchingImportant Pattern Searching Algorithms:Naive String Matching : A Simple Algorithm that works i
2 min read
GeometryGeometry is a branch of mathematics that studies the properties, measurements, and relationships of points, lines, angles, surfaces, and solids. From basic lines and angles to complex structures, it helps us understand the world around us.Geometry for Students and BeginnersThis section covers key br
2 min read
Interview Preparation
Practice Problem