Javatpoint Logo
Javatpoint Logo

Data Structures in Java

The numerous ways that data can be arranged, saved, and handled within a computer program are referred to as data structures in Java. These structures offer a methodical method for handling and managing data effectively, enabling useful operations like insertion, deletion, retrieval, and traversal.

The article will explore everything related to the data structures in Java, and it helps beginners to understand easily and effectively.

  • What is Java?
  • What are Data Structures in Java?
  • Types of Data Structures in Java
  • Advantages of Data Structures in Java
  • Classification of Data Structures
  • Data Structures in Java FAQs

What is Java?

Java is a popular object-oriented programming language renowned for its vast standard library and platform freedom. It offers a solid architecture for creating programs running without recompilation across various platforms. The well-known library for Java has a choice of records systems that make it viable to deal with numerous data types efficiently.

What are Data Structures in Java?

The way that data is organized and stored in a computer program's memory relies closely on Java records structures. The Java well-known library includes a significant type of built-in statistics structures. A few of the records systems that permit programmers short and simple ways to save and arrange data include connected lists, stacks, queues, and arrays. Developers can quickly perform operations like insertion, deletion, searching, and sorting because they provide a range of mechanisms for getting Access to, altering, and managing data. Java programmers can reduce memory use and considerably boost the overall efficiency of their programs by using these data structures.

Types of Data Structures in Java

The list of data structures in Java listed below

  1. Arrays
  2. ArrayList
  3. LinkedList
  4. Stack
  5. Queue
  6. HashMap
  7. HashSet
  8. TreeSet
  9. TreeMap
  10. Graph
  11. Tree

The below diagram clearly explains the types of Data Structures in Java very clearly.

Data Structures in Java

Further classification of types of Data Structures:

There are two types of Data Structures: -

  1. Primitive Data Structures
  2. Non-primitive Data Structures

1) Primitive Data Structures: Also known as primitive data types, these are basic built-in data types in Java. They include:

  • Byte: Stores whole numbers from -128 to 127.
  • short: Stores whole numbers from -32,768 to 32,767.
  • int: Stores whole numbers from -2,147,483,648 to 2,147,483,647.
  • float: Stores floating-point numbers with single precision.
  • char: Stores individual characters.
  • boolean: Stores true or false values.
  • long: Stores large whole numbers.
  • Double: Stores floating-factor numbers with double precision.

2) Non-primitive Data Structures: Non-primitive records structures are more complex and are composed of primitive information sorts. They may be, in addition, categorized into two sorts:

  1. Linear Data Structures: In linear data structures, the elements are arranged linearly or sequentially. Examples include:
    • Arrays: A group of identically-typed elements placed in an array according to a predetermined arrangement.
    • Stacks: A Last-In-First-Out (LIFO) structure in which only the topmost items may be added or removed.
    • Queues: First-In-First-Out (FIFO) structures are utilized in queues, where items are inserted on the returned and taken out on the front.
    • Linked List: A related list comprises a collection of gadgets referred to as nodes, each of which has a reference to the node after it and statistics inside it.
  2. Non-linear Data Structures: In non-linear data structures, the elements are arranged in a non-sequential manner. Examples include:
    • Trees: Trees are a type of node-based hierarchical structure, with a root node at the top and child nodes branching out of it. Examples include red-black trees, AVL trees, binary search trees, and binary trees.
    • Graphs: A set of nodes linked by using edges, wherein nodes may have any quantity of connections. Graphs are used to symbolize complex relationships among items.
    • Heap: A specialized tree-based structure in which every determined node has a value more or smaller than its kids, relying on whether or not it is a max heap or a min heap.
    • Hash: Data structures that use a hash function to map keys to values. Examples consist of hash sets and hash maps, which provide green retrieval and storage of statistics based on precise keys.
Data Structures in Java

Advantages of Data Structures in Java

  1. Efficient Data Organization: Data structures provide organized ways to store and manage data, allowing for efficient Access, manipulation, and retrieval operations. They optimize memory usage and facilitate faster execution of algorithms.
  2. Better Performance: Developers can improve performance in terms of speed and memory utilization by selecting the suitable data structure for a particular activity. Performance is optimized because specific data structures are made to excel at particular actions like searching, sorting, or inserting information.
  3. Code reusability: Java offers a wide range of built-in data structures that are simple for programmers to use. These reusable data structures save time and effort by removing the need to create sophisticated algorithms from scratch.
  4. Code Simplicity: Data structures make the implementation of complicated processes simpler to code. They offer high-level abstractions and encapsulate the specifics of data management, which improves the code's readability, maintainability, and clarity.
  5. Flexibility and Adaptability: Data structures offer flexibility in handling different types and sizes of data. They can dynamically adjust to accommodate changing data requirements and provide mechanisms for efficient data manipulation.
  6. Standardized and Well-Tested: The standard library for Java contains built-in data structures that have undergone significant testing and optimization, guaranteeing their dependability and performance. Utilizing these common data structures lowers the possibility of errors and gives application development a solid foundation.
  7. Scalability: Data structures provide scalability options, allowing applications to handle large volumes of data efficiently. They can dynamically grow or shrink based on the data size, ensuring optimal performance even with increasing data demands.
  8. Algorithm Design: Data structures are crucial in algorithm design and analysis. They provide the underlying structure and operations necessary for implementing various algorithms and solving complex problems.

1) Arrays:

An array is a basic and often used data structure in the context of Java's data structures. It offers a method of storing a fixed-size collection of identical-type components. Because they provide quick and easy access to elements depending on their index, arrays are a crucial tool for managing and organizing data.

Advantages:

  1. Data Organization: Arrays provide a structured way to store and organize elements, improving data management.
  2. Random Access: Elements can be accessed directly using their index, allowing for efficient retrieval and modification.
  3. Fixed Size: Arrays have a predetermined size, enabling efficient memory allocation.
  4. Homogeneous Elements: Arrays store elements of the same type, ensuring data consistency and simplifying operations.
  5. Iteration: Arrays support easy iteration through elements, facilitating traversal and processing.
  6. Sorting and Searching: Arrays work well with sorting and searching algorithms, offering efficient operations.
  7. Memory Efficiency: Arrays optimize memory usage by storing elements in contiguous regions.
  8. Compatibility: Arrays are widely supported in Java, making them compatible with various frameworks and tools.

Disadvantages:

  1. Fixed Size: Arrays cannot be dynamically resized, requiring recreation for size changes.
  2. Memory Wastage: Unused elements in larger arrays can lead to memory wastage.
  3. Insertion and Deletion Overhead: Inserting or deleting elements in the middle of an array requires shifting subsequent elements, resulting in inefficiency.
  4. Lack of Flexibility: Arrays have rigid data types and cannot accommodate different data kinds without additional arrays or data structures.

Functions:

  1. Creating an Array: Declare and initialize an array with a specific size using the array type and the new keyword.
  2. Accessing Elements: Use the index to access individual elements in the array.
  3. Modifying Elements: Update the value of an element by assigning a new value to a specific index in the array.
  4. Finding Length: Use the length attribute to determine the array's length.
  5. Iterating through the Array: Use loops to go through each element in the array and execute

Implementation:

FileName: ArrayExample.java

Output:

Element at index 0:10
Element at index 2:30
Element at index 4:50
Sum of array elements:150
Updated element at index 2:35
Elements in the array:
10
20
35
40
50

2) ArrayList:

ArrayList in Java is a dynamic data structure that allows for the storage and manipulation of elements. It is part of the Java Collections Framework and is implemented using an array internally.

Advantages:

  1. Dynamic Size: Unlike arrays, ArrayLists can dynamically grow or shrink in size as elements are added or removed. It eliminates the need for manual resizing and allows for handling varying amounts of data conveniently.
  2. Easy Element Manipulation: ArrayLists offer methods to add, remove, and modify elements at any position within the list. Its flexibility simplifies common operations such as insertion, deletion, and updating, making element manipulation more efficient.
  3. Random Access: ArrayLists support random Access to elements using their index, enabling quick retrieval and modification of elements at specific positions within the list. It facilitates efficient element access and enhances overall performance.
  4. Compatibility with Java Collection Framework: ArrayLists implement the List interface, making them compatible with other Collection classes in the Java Collections Framework. Its compatibility allows for seamless integration with various algorithms and operations provided by the framework.

Disadvantages:

  1. Higher Memory Overhead: ArrayLists require additional memory to maintain their internal structure, resulting in higher memory overhead compared to arrays. It can be a concern when dealing with large collections of elements.
  2. Slower Insertion and Deletion: Inserting or deleting elements in the middle of an ArrayList requires shifting elements, which can be time-consuming for large lists. In scenarios where frequent insertion or deletion operations are expected, other data structures like LinkedList may offer better performance.
  3. Limited Performance for Search: Searching for an element in an unsorted ArrayList requires iterating over the elements until a match is found. It is a linear search approach that results in slower search performance compared to data structures optimized for searching, such as HashSet or TreeMap.
  4. No Primitive Type Support: ArrayLists can only store objects and do not directly support primitive data types like int or char. To store primitive types, wrapper classes like Integer or Character need to be used, leading to potential autoboxing and unboxing overhead.

Functions:

  1. Creating an ArrayList: Declare and initialize an ArrayList using the ArrayList class and specify the element type within the angle brackets.
  2. Adding Elements: Use the add method to append elements at the end of the ArrayList.
  3. Accessing Elements: Use the get technique to retrieve the price of detail at a selected index.
  4. Modifying Elements: Update the cost of detail at a specific index for the usage of the set approach.
  5. Finding Size: Use the dimensions method to get the cutting-edge quantity of factors in the ArrayList.
  6. Removing Elements: Use the remove approach to delete a detail at a specific index or via providing the object reference.
  7. Iterating through the ArrayList: Use loops to iterate over each element in the ArrayList and perform operations on them.

Implementation:

FileName: ArrayListExample.java

Output:

Element at index 0:10
Element at index 2:30
Element at index 4:50
Sum of ArrayList elements:150
Updated element at index 2:35
Elements in the ArrayList:
10
20
35
40
50

3) Linked List:

A linked list is a linear data structure in which elements are stored in separate objects called nodes. A reference link to the following node in the sequence is included in each node's data element. The list's final node links to null, indicating that the list has ended.

Unlike arrays, linked lists do not require contiguous memory allocation. Each node in a linked list can be allocated independently, allowing for dynamic memory allocation and efficient insertion and deletion operations.

Advantages:

  1. Dynamic Size: LinkedList can grow or shrink dynamically, making it suitable for varying or unknown data sizes.
  2. Efficient Insertion and Deletion: Inserting or deleting elements within a LinkedList is efficient, as it does not require shifting elements.
  3. No Contiguous Memory Requirement: LinkedList does not need contiguous memory allocation, making it flexible and suitable for unpredictable memory situations.
  4. Easy Modification: LinkedList allows easy modification of elements by changing reference pointers, enabling efficient manipulation.

Disadvantages:

  1. Slower Random Access: LinkedList has slower random Access as it requires traversing the list to access elements by index.
  2. Increased Memory Overhead: LinkedList requires additional memory for references and nodes, increasing memory overhead compared to arrays.
  3. Inefficient Search: LinkedList has slower search operations, requiring sequential iteration to find specific elements.

Functions:

  1. Creating a LinkedList: Declare and initialize a LinkedList using the LinkedList class.
  2. Adding Elements: Use the add method to append elements at the end of the LinkedList.
  3. Accessing Elements: Use the get method to retrieve the value of an element at a specific index.
  4. Modifying Elements: Update the value of an element at a particular index using the set method.
  5. Removing Elements: Use the remove method to delete an element at a specific index or by providing the object reference.

Implementation:

FileName: LinkedList1.java

Output:

LinkedList:[10, 20, 30, 40, 50]
LinkedList after removing first element:[20, 30, 40, 50]
LinkedList contains element 30?true
First element:20
Last element:50
LinkedList after clearing:[]

4) Stack:

The Last-In-First-Out (LIFO) principle dictates that the element that was most recently inserted is also the element that is removed first. A stack is a linear data structure that follows this rule. It employs the commands "push" and "pop" to add elements to the stack and, accordingly, remove the top element from the stack. The "peek" technique additionally enables Access to the top element without removing it.

Features of a stack:

  1. LIFO behavior: The last element pushed onto the stack is the first one to be popped out, making it suitable for applications where the order of insertion and removal is important.
  2. Limited Access: Stacks typically provide restricted Access to elements. You can only access the topmost element, and to reach other elements, you need to pop the elements above them.
  3. Dynamic size: Stacks can be implemented using arrays or linked lists, allowing for a dynamic size. They can grow or shrink as needed during runtime.

Advantages:

  1. Simplicity: Stacks are easy to understand and implement.
  2. Efficiency: Insertion and deletion operations have a time complexity of O(1).
  3. Function call management: Stacks efficiently manage function calls and variable storage.
  4. Undo/Redo functionality: Stacks enable undo and redo operations in applications.

Disadvantages:

  1. Limited Access: Access to elements is restricted to the top of the stack.
  2. Size restrictions: Stacks may have size limitations depending on the implementation.
  3. Not suitable for all scenarios: Stacks are specific to LIFO behavior and may not be appropriate in other cases.

Implementation:

FileName: StackExample.java

Output:

Top element:30
Popped element:30
Is stack empty?false
Stack size:2
Stack elements:
10
20

5) Queue:

A queue is a linear data structure in Java that follows the First-In-First-Out (FIFO) principle. It represents a collection of elements where elements are inserted at the rear and removed from the front.

Features:

  1. Enqueue: Adding an element to the rear of the queue.
  2. Dequeue: Removing an element from the front of the queue.
  3. Peek: Retrieve the element at the front of the queue without removing it.
  4. Size: Determining the number of elements in the queue.
  5. Empty Check: Checking if the queue is empty.

Advantages:

  1. FIFO Behavior: Elements are processed in the order of their insertion, ensuring the preservation of the original sequence.
  2. Efficient Insertion and Removal: Adding and removing elements from a queue is fast and has a constant time complexity of O(1).
  3. Synchronization: Java provides synchronized queue implementations, making them safe for concurrent programming.
  4. Standardized Interface: The Queue interface in Java offers a common set of methods, allowing easy interchangeability between different queue implementations.

Disadvantages:

  1. No Random Access: Queues do not support direct Access to elements in the middle. Accessing specific positions requires dequeuing preceding elements.
  2. Limited Size: Some queue implementations have a fixed size or capacity, leading to overflow or exceptions when exceeding the maximum size.
  3. Inefficient Search: Searching for an element in a queue requires dequeuing until a match is found, resulting in a linear search with potentially high time complexity.

Implementation:

FileName: QueueExample.java

Output:

Front element:10
Dequeued element:10
Dequeued element:20
Dequeued element:30
Dequeued element:40
Dequeued element:50

6) HashMap:

A HashMap is a data structure in Java that provides a way to store and retrieve key-value pairs. It is part of the Java Collections Framework and is implemented based on the hash table data structure.

Functions:

  • put(key, value): Inserts the specified key-value pair into the HashMap.
  • get(key): Retrieves the value associated with the specified key.
  • containsKey(key): Checks if the HashMap contains the specified key.
  • containsValue(value): Checks if the HashMap contains the specified value.
  • remove(key): Removes the key-value pair associated with the specified key from the HashMap.
  • size(): Returns the number of key-value pairs in the HashMap.
  • isEmpty(): Checks if the HashMap is empty.
  • keySet(): Returns a Set containing all the keys in the HashMap.
  • values(): Returns a Collection containing all the values in the HashMap.
  • clear(): Removes all the key-value pairs from the HashMap.

Advantages:

  1. Efficient Retrieval: HashMap provides fast retrieval of values based on keys with constant-time complexity O(1).
  2. Flexible Key-Value Pairing: HashMap allows any non-null object as a key, enabling custom-defined keys for storing and retrieving data.
  3. Dynamic Size: HashMap can dynamically grow or shrink in size to handle varying amounts of data.
  4. Compatibility with Java Collections Framework: HashMap implements the Map interface, allowing seamless integration with other Collection classes.

Disadvantages:

  1. Lack of Ordering: HashMap does not preserve the order of elements. Use LinkedHashMap or TreeMap for specific ordering requirements.
  2. Increased Memory Overhead: HashMap requires additional memory for hash codes and internal structure compared to simpler data structures.
  3. Slower Iteration: Iterating over a HashMap can be slower compared to arrays or lists due to traversing the underlying hash table.

Implementation:

FileName: HashMapExample.java

Output:

Age of John:25
Age of Alice:30
Is Bob present?true
Key-Value pairs in the HashMap:
Bob:35
Alice:32
Size of the HashMap:2

7) HashSet:

HashSet is a data structure in Java that implements the Set interface and stores elements in a hash table.

Features:

  1. Stores unique elements: HashSet does not allow duplicate elements. Each element in the HashSet is unique.
  2. Uses hash-based lookup: HashSet uses the hash value of each element to determine its storage location, providing efficient element retrieval.
  3. Unordered collection: The elements in a HashSet are not stored in a specific order. The order of elements may change over time.

Advantages:

  1. Fast element lookup: HashSet provides fast lookup operations, making it efficient to check if an element exists in the set.
  2. No duplicate elements: HashSet automatically handles duplicate elements and ensures that each element is unique.
  3. Integration with Java Collections Framework: HashSet implements the Set interface, making it compatible with other collection classes in the Java Collections Framework.

Disadvantages:

  1. No guaranteed order: HashSet does not maintain the order of elements. If the order of elements is important, HashSet is not suitable.
  2. No indexing: HashSet does not provide direct indexing or positional Access to elements. To access elements, you need to iterate over the set.
  3. Higher memory overhead: HashSet requires additional memory to store hash values and maintain the hash table structure, resulting in higher memory usage compared to some other data structures.

Implementation:

FileName: HashSetExample.java

Output:

HashSet:[Apple, Grapes, Mango, Orange, Banana]
Contains 'Apple':true
Updated HashSet:[Apple, Grapes, Mango, Orange]
Size of HashSet:4
Is HashSet empty?true

8) TreeSet:

TreeSet is an implementation of the SortedSet interface in Java that uses a self-balancing binary search tree called a red-black tree to store elements in sorted order.

Advantages:

  1. Sorted Order: TreeSet automatically maintains the elements in a sorted order based on their natural ordering or a custom comparator. It allows for efficient searching and retrieval of elements in ascending or descending order.
  2. No Duplicate Elements: TreeSet does not allow duplicate elements. It ensures that each element in the set is unique, which can be useful in scenarios where duplicate values should be avoided.
  3. Efficient Operations: TreeSet provides efficient operations like insertion, deletion, and searching. These operations have a time complexity of O(log n), where n is the number of elements in the set.
  4. Navigable Set Operations: TreeSet provides additional navigational methods, such as higher(), lower(), ceiling(), and floor(), which allow you to find elements that are greater than, less than, or equal to a given value.

Disadvantages:

  1. Overhead: TreeSet requires additional memory to store the internal data structure, which can lead to higher memory overhead compared to other set implementations.
  2. Slower Insertion and Removal: Insertion and removal operations in TreeSet involve maintaining the sorted order of elements, which may require tree restructuring. It can make these operations slightly slower compared to HashSet or LinkedHashSet.
  3. Limited Customization: TreeSet is primarily designed for natural ordering or a single custom comparator. It may need more flexibility for multiple sorting criteria or complex sorting logic.

Functions:

  • add(element): Adds an element to the TreeSet while maintaining the sorted order.
  • remove(element): Removes the specified element from the TreeSet.
  • contains(element): Checks if the TreeSet contains the specified element.
  • size(): Returns the number of elements in the TreeSet.
  • first(): Returns the first (lowest) element in the TreeSet.
  • last(): Returns the last (highest) element in the TreeSet.
  • higher(element): Returns the least element in the TreeSet that is strictly greater than the given element.
  • lower(element): Returns the greatest element in the TreeSet that is strictly less than the given element.

Implementation:

FileName: TreeSetExample.java

Output:

Elements in the TreeSet:[1, 2, 4, 5, 8]
Does TreeSet contain 4? true
Elements in the TreeSet after removal:[1, 4, 5, 8]
Size of the TreeSet:4First element:1
Last element:8
Iterating over the TreeSet:
1
4
5
8

9) TreeMap:

TreeMap is a class in Java that implements the Map interface and provides a sorted key-value mapping based on the natural order of the keys or a custom comparator.

Advantages:

  1. Sorted Ordering: TreeMap maintains the keys in sorted order, which allows for efficient searching, retrieval, and range-based operations.
  2. Key-Value Mapping: TreeMap stores key-value pairs, enabling efficient lookup and retrieval of values based on the associated keys.
  3. Red-Black Tree Implementation: TreeMap uses a balanced binary search tree (Red-Black Tree) internally, ensuring efficient performance even for large datasets.
  4. Support for Custom Comparators: TreeMap allows the use of custom comparators to define the sorting order of the keys, providing flexibility in sorting criteria.

Disadvantages:

  1. Memory Overhead: TreeMap requires additional memory to store the internal tree structure and associated objects, resulting in higher memory usage compared to simpler data structures like HashMap.
  2. Slower Insertion and Deletion: Insertion and deletion operations in TreeMap have a time complexity of O(log n) due to the need for tree restructuring, making them slower compared to HashMap or LinkedHashMap.
  3. Limited Performance for Unsorted Data: TreeMap performs efficiently for sorted data, but its performance can degrade when dealing with unsorted data or frequent modifications, as it requires maintaining the sorted order.

Functions:

  • put(key, value): Inserts a key-value pair into the TreeMap.
  • get(key): Retrieves the value associated with the specified key.
  • containsKey(key): Checks if the TreeMap contains a specific key.
  • remove(key): Removes the key-value pair associated with the specified key.
  • size(): Returns the number of key-value pairs in the TreeMap.
  • keySet(): Returns a set of all keys in the TreeMap.
  • values(): Returns a collection of all values in the TreeMap.
  • entrySet(): Returns a set of key-value pairs in the TreeMap.

Implementation:

FileName: TreeMapExample.java

Output:

Score of Alice:90
Score of Charlie:95
Score of David:87
Scores in the TreeMap:
Alice:90
Bob:85
Charlie:95
David:87

10) Graph:

Graphs are data structure that represents a collection of interconnected nodes or vertices. They are composed of vertices and edges, where vertices represent entities and edges represent the relationships between those entities.

Advantages:

  1. Versatility: Graphs can represent a wide range of real-world scenarios, making them suitable for various applications such as social networks, transportation systems, and computer networks.
  2. Relationship Representation: Graphs provide a natural way to represent relationships and connections between entities, allowing for efficient analysis and traversal of these relationships.
  3. Efficient Search and Traversal: Graph algorithms like breadth-first search (BFS) and depth-first search (DFS) enable efficient traversal and searching of the graph's vertices and edges.
  4. Modeling Complex Relationships: Graphs can model complex relationships, including hierarchical structures, cyclic dependencies, and multiple connections between entities.

Disadvantages:

  1. Space Complexity: Graphs can consume a significant amount of memory, especially large-scale graphs with many vertices and edges.
  2. The complexity of Operations: Certain graph operations, such as finding the shortest path or detecting cycles, can have high time complexity, particularly in dense graphs.
  3. Difficulty in Maintenance: Modifying or updating a graph can be complex, as changes in the graph's structure may impact its connectivity and existing algorithms.

Implementation:

FileName: GraphExample.java

Output:

BFS traversal: 0 1 2 3 4 
DFS traversal: 0 1 3 2 4

11) Tree:

A tree is a widely used data structure in computer science that represents a hierarchical structure. It consists of nodes connected by edges, where each node can have zero or more child nodes.

Advantages:

  1. Hierarchical Structure: Trees provide a natural way to represent hierarchical relationships, such as file systems, organization charts, or HTML/XML documents.
  2. Efficient Search: Binary search trees enable efficient searching with a time complexity of O(log n), making them suitable for storing and retrieving sorted data.
  3. Fast Insertion and Deletion: Tree data structures offer efficient insertion and deletion operations, especially when balanced, such as AVL trees or Red-Black trees.
  4. Ordered Iteration: In-order traversal of a binary search tree gives elements in a sorted order, which is helpful for tasks like printing elements in sorted order or finding the next/previous element.

Disadvantages:

  1. High Memory Overhead: Trees require additional memory to store node references or pointers, which can result in higher memory usage compared to linear data structures like arrays or lists.
  2. Complex Implementation: Implementing and maintaining a tree data structure can be more complex compared to other data structures like arrays or lists, especially for balanced tree variants.
  3. Limited Operations: Some tree variants, like binary search trees, do not support efficient operations like finding the kth smallest element or finding the rank of an element.

Functions:

  1. Insertion: Add a new node to the tree.
  2. Deletion: Remove a node from the tree.
  3. Search: Find a specific node or element in the tree.
  4. Traversal: Traverse the tree in different orders, such as in-order, pre-order, or post-order.
  5. Height/Depth: Calculate the height or depth of the tree.
  6. Balance: Ensure the tree remains balanced to maintain efficient operations.

Implementation:

FileName: TreeExample.java

Output:

In-order Traversal:20 30 40 50 60 70 80 
Search for value 40: true
Search for value 90: false
Minimum value in the tree: 20
Maximum value in the tree: 80






Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA