Skip to content

Here, you will find a collection of coding projects and solutions related to Data Structures and Algorithms (DSA) that I worked on during my 3rd semester. These projects showcase my journey in mastering DSA concepts and implementing them in java programming languages.

Notifications You must be signed in to change notification settings

prashant0ngx/dsa-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Data Structure and Algorithm with Java

1. LinkedList

  • Singly Linked List

    package LinkedList;
    
    /**
     *
     * @author Prashant
     */
    
    class SLL{
        class Node{
            int info;
            Node next;
            public Node(int data){
                info=data;
                next=null;
    
            }
        }
        public Node head=null;
        public Node tail=null;
        //addFirst
        public void addFirst(int data){
            Node n1 =new Node(data);
            if(head==null){
                head=n1;
                tail = n1;
            }
            else{
                n1.next=head;
                head=n1;
            }
        }
        //addLast
        public void addLast(int data){
            Node n1= new Node(data);
            if(head==null){
                head=n1;
                tail=n1;
            }
            else{
                tail.next=n1;
                tail=n1;
            }
        }
        //addAtSpecificPosition
        public void addAtSpecificPosition(int data,int pos){
            Node n1=new Node(data);
            if(head==null){
                head=n1;
                tail=n1;
            }
            else{
                Node temp=head;
                for(int i=1;i<pos-1;i++){
                    temp=temp.next;
                }
                n1.next=temp.next;
                temp.next=n1;
            }
        }
        //deleteFirst
        public void deleteFirst(){
            if(head==null){
                System.out.println("List is empty");
            }
            else{
                head=head.next;
            }
        }
        //deleteLast
        public void deleteLast(){
            if(head==null){
                System.out.println("List is empty");
            }
            else{
                Node temp=head;
                while(temp.next!=null){
                    temp=temp.next;
                }
                temp.next=null;
                tail=temp;
            }
        }
        //deleteAtSpecificPosition
        public void deleteAtSpecificPosition(int pos){
            if(head==null){
                System.out.println("List is empty");
            }
            else{
                Node temp=head;
                for(int i=1;i<pos-1;i++){
                    temp=temp.next;
                }
                temp.next=temp.next.next;
            }
        }
        //display
        public void display(){
            Node temp=head;
            if(head==null){
                System.out.println("List is empty");
            }
            while(temp!=null){
                System.out.print(temp.info+"=>");
                temp=temp.next;
            }
            System.out.println();
        }
        //searchItem
        public void searchItem(int data){
            Node temp=head;
            int count=0;
            int d=0;
            while(temp!=null){
                if(temp.info==data){
                    count++;
                    d=temp.info;
                    break;
                }
                temp=temp.next;
            }
            if(count==0){
                System.out.println("Item not found");
            }
            else{
                System.out.println("Item found : "+ d);
            }
        }
    
        //main function write yourself
    } 
  • Circular Singly Linked List

  • Doubly Linked List

  • Circular Doubly Linked List

2. Queue

  • Linear Queue
  • Circular Queue

3. Recursion

  • Factorial
  • Fibonacci Recursive
  • isPrime Recursive
  • SquareOfN
  • SumOfNaturalNumber
  • Tower Of Hannoi

4. Sorting

  • Bubble Sort
  • Insertion Sort
  • Quick Sort
  • Selection Sort

5. Stack

  • Stack Implementation with array
  • Stack Implementation with LinkedList

© Prashant Bhandari 2023

About

Here, you will find a collection of coding projects and solutions related to Data Structures and Algorithms (DSA) that I worked on during my 3rd semester. These projects showcase my journey in mastering DSA concepts and implementing them in java programming languages.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages