Package adt

Examples of adt.LinkedList


import adt.LinkedList;

public class Q015_Pairwise_Swap_Elements_Of_A_Given_Linked_List {

  public static void main(String[] args) {
    LinkedList list = new LinkedList(5);
    pairSwap(list);
   
    //pairSwapR(list.head);
    list.print();
  }
View Full Code Here


public class Q012C_Remove_Duplicates_From_Unsorted_Linked_List {
 
  public static void main(String[] args) {
    int[] arr = {12, 11, 12, 21, 41, 43, 21};
    LinkedList list = new LinkedList(arr);
   
    ListNode head = removeDups(list);
    head.print();
  }
View Full Code Here

import adt.LinkedList;

public class Q032_Sort_a_linked_list_of_0s_1s_and_2s {

  public static void main(String[] args) {
    LinkedList list = new LinkedList(new int[]{0, 1, 0, 2, 1, 1, 2, 1, 2});
    ListNode res = sortList(list.head);
    res.print();
  }
View Full Code Here

import adt.LinkedList;

public class Q021_Identical_Linked_Lists {

  public static void main(String[] args) {
    LinkedList a = new LinkedList(new int[]{1, 2, 3});
    LinkedList b = new LinkedList(new int[]{1, 2, 3});
   
    boolean res = isIdentical(a.head, b.head);
    System.out.println(res);
  }
View Full Code Here

    return p;
  }
 
  public static void main(String[] args) {
    // Initialize a linked list
    LinkedList list = new LinkedList(10);
   
    ListNode node = getNth(list.head, 5);
   
    if (node != null) {
      System.out.println(node.val);
View Full Code Here

public class Q012B_Remove_Duplicates_From_Sorted_Linked_List {

  public static void main(String[] args) {
    int[] arr = {11, 11, 11, 21, 43, 43, 60};
    LinkedList list = new LinkedList(arr);
   
    ListNode head = removeDups(list);
    head.print();
  }
View Full Code Here

import adt.LinkedList;

public class Q018_Delete_Alternate_Nodes_of_Linked_List {

  public static void main(String[] args) {
    LinkedList list = new LinkedList(5);
    deleteAlternate(list);
    list.print();
  }
View Full Code Here

import adt.LinkedList;

public class Q023_Delete_Nodes_Which_Have_A_Greater_Value_On_Right_Side {

  public static void main(String[] args) {
    LinkedList list = new LinkedList(new int[]{12, 15, 10, 11, 5, 6, 2, 3});
    deleteGreaterNodes(list.head);
  }
View Full Code Here

import adt.LinkedList;

public class Q029_Rotate_a_Linked_List {

  public static void main(String[] args) {
    LinkedList list = new LinkedList(new int[]{10, 20, 30, 40, 50, 60});
    leftRotate(list, 4);
    list.print();
  }
View Full Code Here

public class Q026B_Sorted_Linked_List_to_Balanced_BST {
 
  static ListNode head;
 
  public static void main(String[] args) {
    LinkedList list = new LinkedList(new int[]{1, 2, 3, 4, 5, 6, 7});
    head = list.head;
    TreeNode root = sortedListToBST(7);
    root.print();
  }
View Full Code Here

TOP

Related Classes of adt.LinkedList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.