A Java implementation of efficient data structures for integer values. More data structures may be added in the future. This is done for educational purposes and to provide a foundation for more complex data manipulation tasks.
This project provides specialized data structures for working with integer values. The implementations use linked lists as the underlying storage mechanism, offering efficient memory usage and flexible operations.
A basic node class that serves as the building block for the linked data structures. Each node contains:
- An integer data value
- A reference to the next node
A queue implementation for integers using a linked list. Follows the FIFO (First-In-First-Out) principle.
Basic Operations:
add(int x)
: Adds an element to the end of the queueremove()
: Removes and returns the element at the front of the queueelement()
: Returns the element at the front without removing itempty()
: Checks if the queue is emptysize()
: Returns the number of elements in the queue
Advanced Operations:
cut(int n)
: Keeps the first n elements and returns a new queue with the remaining elementsmirrorize()
: Adds a mirror image of the queue to itselfreverse()
: Reverses the order of elementsswapThirds()
: Divides the queue into three parts and rearranges themremoveRepeatedValues()
: Removes duplicate valuesaddSorted(int d)
: Adds an element in sorted ordersplit(int x)
: Splits the queue based on a value x
A stack implementation for integers using a linked list. Follows the LIFO (Last-In-First-Out) principle.
Basic Operations:
push(int x)
: Adds an element to the top of the stackpop()
: Removes and returns the element at the top of the stackpeek()
: Returns the element at the top without removing itempty()
: Checks if the stack is emptysize()
: Returns the number of elements in the stack
Advanced Operations:
get(int i)
: Returns the element at the specified positiontopBase()
: Moves the bottom element to the top and sets its value to the original top valuepushR(int x)
: Pushes an element after its last occurrence in the stack
QueueIntLinked queue = new QueueIntLinked();
queue.add(1);
queue.add(2);
queue.add(3);
StackIntLinked stack = new StackIntLinked();
stack.push(1);
stack.push(2);
stack.push(3);
- Efficient memory usage with linked list implementation
- Comprehensive set of operations beyond standard interfaces
- Specialized for integer values
- Advanced manipulation methods for complex data operations