示例#1
0
    public void quadraticHashInsert(int key)
    {
        //quadratic probing method
        if (!checkOpenSpace())//if no open spaces available
        {
            Console.WriteLine("table is at full capacity!");
            return;
        }

        if (Search(key))
        {
            Console.WriteLine("Key already exists!");
            return;
        }

        int j    = 0;
        int hash = HashTabQuadProb.hash(key);

        while (table[hash] != null)
        {
            j++;
            hash = mod((HashTabQuadProb.hash(key) + (j * j)), maxSize);
            if (table[hash] != null)
            {
                hash = mod((HashTabQuadProb.hash(key) + ((j * j) * -1)), maxSize);
            }
        }
        if (table[hash] == null)
        {
            table[hash] = new HashProbe(key, key);
            return;
        }
    }
        public void InsertTest()
        {
            HashTabQuadProb a = new HashTabQuadProb();

            Assert.IsTrue(a.Insert(76));
            Assert.IsTrue(a.Insert(40));
            Assert.IsTrue(a.Insert(0));
            Assert.IsTrue(a.Insert(48));
            Assert.IsTrue(a.Insert(5));
            Assert.IsTrue(a.Insert(20));
            a.Print();
        }
        public void BlockedCells()
        {
            HashTabQuadProb a = new HashTabQuadProb();

            Assert.IsTrue(a.Insert(7));
            Assert.IsTrue(a.Insert(14));
            Assert.IsTrue(a.Insert(21));
            Assert.IsTrue(a.Delete(7));
            Assert.IsTrue(a.Delete(21));
            Assert.IsFalse(a.Insert(14));
            Assert.IsTrue(a.Insert(21));
            Assert.IsTrue(a.Insert(7));
            a.Print();
        }
        public void MultipleDeleteTest()
        {
            HashTabQuadProb a = new HashTabQuadProb();

            a.Insert(7);
            a.Insert(14);
            a.Insert(21);

            a.Delete(7);
            a.Delete(14);

            a.Insert(21);
            a.Insert(28);
            a.Print();
        }
        public void DeleteTest()
        {
            HashTabQuadProb a = new HashTabQuadProb();

            Assert.IsTrue(a.Insert(76));
            Assert.IsTrue(a.Insert(40));
            Assert.IsTrue(a.Insert(0));
            Assert.IsTrue(a.Insert(48));
            Assert.IsTrue(a.Insert(5));
            Assert.IsTrue(a.Insert(20));
            a.Delete(76);
            Assert.IsFalse(a.Search(76));
            Assert.IsFalse(a.Delete(100));
            a.Print();
        }
        public void SearchAfterDelete()
        {
            HashTabQuadProb a = new HashTabQuadProb();

            a.Insert(7);
            a.Insert(14);
            a.Insert(21);
            a.Insert(28);

            a.Delete(7);
            a.Delete(14);
            a.Delete(21);

            Assert.IsTrue(a.Search(28));
            a.Insert(14);
            a.Insert(21);
            Assert.IsFalse(a.Insert(28));
            Assert.IsTrue(a.Search(28));
            a.Print();
        }
        public void InsertTest_PlaceObject_on_HashFuncPos()
        {
            // Setup
            HashTabQuadProb a = new HashTabQuadProb();

            a.Insert(7);
            a.Insert(14);
            a.Insert(21);
            a.Delete(14);
            a.Insert(28);
            a.Insert(45);
            a.Insert(5);
            Console.WriteLine("after setup");
            a.Print();
            // Action
            var res = a.Insert(49);

            Console.WriteLine("after action");
            a.Print();
            // Assert
            Assert.IsTrue(res);
        }
        public void SearchTest()
        {
            HashTabQuadProb a = new HashTabQuadProb();

            Assert.IsTrue(a.Insert(76));
            Assert.IsTrue(a.Insert(40));
            Assert.IsTrue(a.Insert(0));
            Assert.IsTrue(a.Insert(48));
            Assert.IsTrue(a.Insert(5));
            Assert.IsTrue(a.Insert(20));

            Assert.IsTrue(a.Search(76));
            Assert.IsTrue(a.Search(40));
            Assert.IsTrue(a.Search(48));
            Assert.IsTrue(a.Search(5));
            Assert.IsTrue(a.Search(20));
            Assert.IsTrue(a.Search(0));
            Assert.IsFalse(a.Search(2));
            Assert.IsTrue(a.Insert(8));
            Assert.IsFalse(a.Insert(11));
            Assert.IsFalse(a.Insert(76));
            a.Print();
        }
        public void ReallocationTest_thinker_to_HashFuncNeg()
        {
            // Setup
            HashTabQuadProb a = new HashTabQuadProb();

            a.Insert(7);
            a.Insert(14);
            a.Insert(21);
            a.Insert(28);
            a.Insert(35);
            a.Insert(42);
            a.Insert(49);
            a.Delete(28);
            Console.WriteLine("after setup");
            a.Print();
            // Action
            var res = a.Insert(5);

            Console.WriteLine("after action");
            a.Print();
            // Assert
            Assert.IsTrue(res);
        }
示例#10
0
    public bool Search(int key)
    {
        int j    = 0;
        int hash = HashTabQuadProb.hash(key);

        while (table[hash] != null && table[hash].getkey() != key)
        {
            j++;
            hash = mod((HashTabQuadProb.hash(key) + (j * j)), maxSize);
            if (table[hash] != null)
            {
                hash = mod((HashTabQuadProb.hash(key) + ((j * j) * -1)), maxSize);
            }
        }
        if (table[hash] == null)
        {
            return(false);
        }
        else
        {
            Console.WriteLine("Der Schlüssel " + key + " ist im folgenden hash gespeichert: " + hash);
            return(true);
        }
    }
示例#11
0
    public bool Delete(int key)
    {
        int j    = 0;
        int hash = HashTabQuadProb.hash(key);

        while (table[hash] != null && table[hash].getkey() != key)
        {
            j++;
            hash = mod((HashTabQuadProb.hash(key) + (j * j)), maxSize);
            if (table[hash] != null)
            {
                hash = mod((HashTabQuadProb.hash(key) + ((j * j) * -1)), maxSize);
            }
        }
        if (table[hash] == null)
        {
            return(false);
        }
        else
        {
            table[hash] = null;
            return(true);
        }
    }
示例#12
0
        static void Main()
        {
            IDictionary idict     = null;
            bool        run       = true;
            int         arraySize = 0;

            while (run)
            {
                //Auswahlebene (Wörterbucharten)
                Console.WriteLine("------Menü------");
                Console.WriteLine("Wählen Sie ein Dictionary aus:");
                Console.WriteLine("1. IMultiSet");
                Console.WriteLine("2. IMultiSetSorted");
                Console.WriteLine("3. ISet");
                Console.WriteLine("4. ISetSorted");
                Console.WriteLine("5. Programm beenden");


                int eingabe = -1;

                bool eingabeGueltig = false;
                while (!eingabeGueltig)
                {
                    try
                    {
                        eingabe = Convert.ToInt32(Console.ReadLine());
                        while (eingabe > 5 || eingabe < 1)
                        {
                            Console.WriteLine("Eingabe ungültig, bitte wählen Sie eine Zahl zwischen 1 und 5.");
                            eingabe = Convert.ToInt32(Console.ReadLine());
                        }
                        eingabeGueltig = true;
                    }
                    catch (OverflowException)
                    {
                        Console.WriteLine("{0} ist zu groß, bitte neue Zahl eingeben!", eingabe);
                    }
                    catch (FormatException)
                    {
                        Console.WriteLine("Es wurde keine Zahl eingegeben, bitte neue Zahl eingeben");
                    }
                }
                if (eingabe == 5)
                {
                    eingabeGueltig = true;
                    run            = false;
                    break;
                }
                switch (eingabe)
                {
                case 1:
                    Console.WriteLine("Sie haben IMultiSet ausgewählt");
                    Console.WriteLine("Wählen Sie ein Dictionary aus:");
                    Console.WriteLine("1. MultiSetUnsortedList");
                    Console.WriteLine("2. MultiSetUnsortedArray");

                    eingabeGueltig = false;
                    while (!eingabeGueltig)
                    {
                        try
                        {
                            eingabe = Convert.ToInt32(Console.ReadLine());
                            while (eingabe > 2 || eingabe < 1)
                            {
                                Console.WriteLine("Eingabe ungültig, bitte Wählen Sie zwischen 1 und 2");
                                eingabe = Convert.ToInt32(Console.ReadLine());
                            }
                            eingabeGueltig = true;
                        }
                        catch (OverflowException)
                        {
                            Console.WriteLine("{0} ist zu groß, bitte neue Zahl eingeben!", eingabe);
                        }
                        catch (FormatException)
                        {
                            Console.WriteLine("Es wurde keine Zahl eingegeben, bitte neue Zahl eingeben");
                        }
                    }

                    //Weitere Auswahl
                    switch (eingabe)
                    {
                    case 1:
                        Console.WriteLine("Sie haben MultiSetUnsortedList ausgewählt");
                        idict = new MultiSetUnsortedLinkedList();
                        break;

                    case 2:
                        Console.WriteLine("Sie haben MultiSetUnsortedArray ausgewählt");
                        Console.WriteLine("Wieviele Werte möchten Sie speichern?");
                        arraySize = Convert.ToInt32(Console.ReadLine());
                        idict     = new MultiSetUnsortedArray(arraySize);
                        break;

                    default:
                        Console.WriteLine("Eingabe ist ungültig");
                        break;
                    }
                    break;

                case 2:
                    Console.WriteLine("Sie haben IMultiSetSorted ausgewählt");
                    Console.WriteLine("Wählen Sie ein Dictionary aus:");
                    Console.WriteLine("1. MultiSetSortedList");
                    Console.WriteLine("2. MultiSetSortedArray");

                    eingabeGueltig = false;
                    while (!eingabeGueltig)
                    {
                        try
                        {
                            eingabe = Convert.ToInt32(Console.ReadLine());
                            while (eingabe > 2 || eingabe < 1)
                            {
                                Console.WriteLine("Eingabe ungültig, bitte wählen Sie 1 oder 2");
                                eingabe = Convert.ToInt32(Console.ReadLine());
                            }
                            eingabeGueltig = true;
                        }
                        catch (OverflowException)
                        {
                            Console.WriteLine("{0} ist zu groß, bitte neue Zahl eingeben!", eingabe);
                        }
                        catch (FormatException)
                        {
                            Console.WriteLine("Es wurde keine Zahl eingegeben, bitte neue Zahl eingeben");
                        }
                    }

                    //weitere Auswahl
                    switch (eingabe)
                    {
                    case 1:
                        Console.WriteLine("Sie haben MultiSetSortedList ausgewählt");
                        idict = new MultiSetSortedLinkedList();
                        break;

                    case 2:
                        Console.WriteLine("Sie haben MultiSetSortedArray ausgewählt");
                        Console.WriteLine("Wieviele Werte möchten Sie speichern?");
                        arraySize = Convert.ToInt32(Console.ReadLine());
                        idict     = new MultiSetSortedArray(arraySize);
                        break;
                    }
                    break;

                case 3:
                    Console.WriteLine("Sie haben ISet ausgewählt");
                    Console.WriteLine("Wählen Sie ein Dictionary aus:");
                    Console.WriteLine("1. SetUnsortedList");
                    Console.WriteLine("2. SetUnsortedArray");
                    Console.WriteLine("3. HashTableQuadProb");
                    Console.WriteLine("4. HashTableSepChain");

                    eingabeGueltig = false;
                    while (!eingabeGueltig)
                    {
                        try
                        {
                            eingabe = Convert.ToInt32(Console.ReadLine());
                            while (eingabe > 4 || eingabe < 1)
                            {
                                Console.WriteLine("Eingabe ungültig, bitte wählen Sie eine Zahl zwischen 1 und 4.");
                                eingabe = Convert.ToInt32(Console.ReadLine());
                            }
                            eingabeGueltig = true;
                        }
                        catch (OverflowException)
                        {
                            Console.WriteLine("{0} ist zu groß, bitte neue Zahl eingeben!", eingabe);
                        }
                        catch (FormatException)
                        {
                            Console.WriteLine("Es wurde keine Zahl eingegeben, bitte neue Zahl eingeben");
                        }
                    }

                    //weitere Auswahl
                    switch (eingabe)
                    {
                    case 1:
                        Console.WriteLine("Sie haben SetUnsortedList ausgewählt");
                        idict = new SetUnsortedLinkedList();
                        break;

                    case 2:
                        Console.WriteLine("Sie haben SetUnsortedArray ausgewählt");
                        Console.WriteLine("Wieviele Werte möchten Sie speichern?");
                        arraySize = Convert.ToInt32(Console.ReadLine());
                        idict     = new SetUnsortedArray(arraySize);
                        break;

                    case 3:
                        Console.WriteLine("Es wurde HashTableQuadProb gewählt\nBitte geben sie die Größe der Tabelle ein:");
                        int maxSizeQuadProb = Convert.ToInt32(Console.ReadLine());
                        idict = new HashTabQuadProb(maxSizeQuadProb);
                        break;

                    case 4:
                        Console.WriteLine("Es wurde HashTableSepChain gewählt\nBitte geben sie die Größe der Tabelle ein:");
                        int maxSizeSepChain = Convert.ToInt32(Console.ReadLine());
                        idict = new HashTabSepChain(maxSizeSepChain);
                        break;

                    default:
                        Console.WriteLine("Ungültige Eingabe");
                        break;
                    }
                    break;

                case 4:
                    Console.WriteLine("Sie haben ISetSorted ausgewählt");
                    Console.WriteLine("Wählen Sie ein Dictionary aus:");
                    Console.WriteLine("1. SetSortedLinkedList");
                    Console.WriteLine("2. SetSortedArray");
                    Console.WriteLine("3. binärer Suchbaum");
                    Console.WriteLine("4. AVL Baum");
                    Console.WriteLine("5. Treap");

                    //eingabe = Convert.ToInt32(Console.ReadLine());
                    eingabeGueltig = false;
                    while (!eingabeGueltig)
                    {
                        try
                        {
                            eingabe = Convert.ToInt32(Console.ReadLine());
                            while (eingabe > 5 || eingabe < 1)
                            {
                                Console.WriteLine("Eingabe ungültig, bitte wählen Sie eine Zahl zwischen 1 und 5.");
                                eingabe = Convert.ToInt32(Console.ReadLine());
                            }
                            eingabeGueltig = true;
                        }
                        catch (OverflowException)
                        {
                            Console.WriteLine("{0} ist zu groß, bitte neue Zahl eingeben!", eingabe);
                        }
                        catch (FormatException)
                        {
                            Console.WriteLine("Es wurde keine Zahl eingegeben, bitte neue Zahl eingeben");
                        }
                    }
                    //weitere Auswahl
                    switch (eingabe)
                    {
                    case 1:
                        Console.WriteLine("Sie haben SetSortedLinkedList ausgewählt");
                        idict = new SetSortedLinkedList();
                        break;

                    case 2:
                        Console.WriteLine("Sie haben SetSortedArray ausgewählt");
                        Console.WriteLine("Wieviele Werte möchten Sie speichern?");
                        arraySize = Convert.ToInt32(Console.ReadLine());
                        idict     = new SetSortedArray(arraySize);
                        break;

                    case 3:
                        Console.WriteLine("Sie haben Binary Search Tree ausgewählt");
                        idict = new BinSearchTree();
                        break;

                    case 4:
                        Console.WriteLine("Sie haben AVL Tree ausgewählt");
                        idict = new AVLTree();
                        break;

                    case 5:
                        Console.WriteLine("Sie haben Treap ausgewählt");
                        idict = new Treap();
                        break;

                    default:
                        Console.WriteLine("Eingabe ist nicht gültig");
                        break;
                    }
                    break;
                }
                bool agieren;
                do
                {
                    //Auswahlebene (Aktionen)
                    Console.WriteLine();
                    Console.WriteLine("Bitte wählen Sie eine Funktion aus:");
                    Console.WriteLine("(I)nsert");
                    Console.WriteLine("(S)earch");
                    Console.WriteLine("(D)elete");
                    Console.WriteLine("(P)rint");
                    Console.WriteLine("(Z)urück zum Hauptmenü");

                    string aktion      = Console.ReadLine();
                    bool   eingGueltig = false;
                    bool   feedback    = false;
                    int    wert        = 0;
                    agieren = true;

                    switch (aktion)
                    {
                    //Aktion Insert
                    case "i":
                    case "I":
                        Console.WriteLine("Sie haben Insert ausgewählt");

                        if (idict.GetType().ToString().Equals("HashTabQuadProb") || idict.GetType().ToString().Equals("HashTabSepChain"))
                        {
                            Console.WriteLine("Geben Sie bitte einen Schlüssel ein: ");
                        }
                        else
                        {
                            Console.WriteLine("Geben Sie bitte einen Wert ein: ");
                        }


                        eingGueltig = false;
                        while (!eingGueltig)
                        {
                            try
                            {
                                wert        = Convert.ToInt32(Console.ReadLine());
                                eingGueltig = true;
                            }
                            catch (OverflowException)
                            {
                                Console.WriteLine("{0} ist zu groß, bitte neue Zahl eingeben!", wert);
                            }
                            catch (FormatException)
                            {
                                Console.WriteLine("Es wurde keine Zahl eingegeben, bitte neue Zahl eingeben");
                            }
                        }

                        feedback = idict.Insert(wert); //Hier wird feedback gesetzt ob die Aktion erfolgreich war oder nicht

                        //Zahl existiert bereits NUR FÜR SET; NICHT MULTISET
                        if (feedback == false)
                        {
                            if (idict.GetType().ToString().Equals("HashTabQuadProb") || idict.GetType().ToString().Equals("HashTabSepChain"))
                            {
                                Console.WriteLine("Der eingegebene Schlüssel ist also schon vorhanden!");
                            }

                            else
                            {
                                Console.WriteLine("Die eingegebene Zahl ist bereits vorhanden!");
                            }
                        }
                        else
                        {
                            if (idict.GetType().ToString().Equals("HashTabQuadProb") || idict.GetType().ToString().Equals("HashTabSepChain"))
                            {
                                if (HashTabQuadProb.checkOpenSpace() == false)
                                {
                                    Console.WriteLine("");
                                }
                                else
                                {
                                    Console.WriteLine("{0} wurde eingefügt", wert);
                                }
                            }

                            else
                            {
                                Console.WriteLine("{0} wurde eingefügt", wert);
                            }
                        }
                        break;

                    //Aktion Search
                    case "s":
                    case "S":
                        Console.WriteLine("Sie haben Search ausgewählt");

                        if (idict.GetType().ToString().Equals("HashTabQuadProb") || idict.GetType().ToString().Equals("HashTabSepChain"))
                        {
                            Console.WriteLine("Bitte geben Sie den Schlüssel ein, der gesucht werden soll:");
                        }
                        else
                        {
                            Console.WriteLine("Bitte geben Sie die Zahl ein, die gesucht werden soll:");
                        }


                        eingGueltig = false;
                        while (!eingGueltig)
                        {
                            try
                            {
                                wert        = Convert.ToInt32(Console.ReadLine());
                                eingGueltig = true;
                            }
                            catch (OverflowException)
                            {
                                Console.WriteLine("{0} ist zu groß, bitte neue Zahl eingeben!", wert);
                            }
                            catch (FormatException)
                            {
                                Console.WriteLine("Es wurde keine Zahl eingegeben, bitte neue Zahl eingeben");
                            }
                            feedback = idict.Search(wert);
                        }
                        if (feedback == true)
                        {
                            if (idict.GetType().ToString().Equals("HashTabQuadProb") || idict.GetType().ToString().Equals("HashTabSepChain"))
                            {
                                Console.WriteLine("Schlüssel {0} wurde gefunden", wert);
                            }
                            else
                            {
                                Console.WriteLine("Zahl {0} wurde gefunden", wert);
                            }
                        }
                        else
                        if (idict.GetType().ToString().Equals("HashTabQuadProb") || idict.GetType().ToString().Equals("HashTabSepChain"))
                        {
                            Console.WriteLine("Der Schlüssel {0} wurde nicht gefunden", wert);
                        }
                        else
                        {
                            Console.WriteLine("Die Zahl {0} wurde nicht gefunden", wert);
                        }


                        break;
                    //Aktion Delete

                    case "d":
                    case "D":
                        Console.WriteLine("Sie haben Delete ausgewählt");

                        if (idict.GetType().ToString().Equals("HashTabQuadProb") || idict.GetType().ToString().Equals("HashTabSepChain"))
                        {
                            Console.WriteLine("Bitte geben Sie den Schlüssel ein der gelöscht werden soll!");
                        }
                        else
                        {
                            Console.WriteLine("Bitte geben Sie die Zahl ein, die gelöscht werden soll.");
                        }

                        eingGueltig = false;
                        while (!eingGueltig)
                        {
                            try
                            {
                                wert        = Convert.ToInt32(Console.ReadLine());
                                eingGueltig = true;
                            }
                            catch (OverflowException)
                            {
                                Console.WriteLine("{0} ist zu groß, bitte neue Zahl eingeben!", wert);
                            }
                            catch (FormatException)
                            {
                                Console.WriteLine("Es wurde keine Zahl eingegeben, bitte neue Zahl eingeben");
                            }
                            feedback = idict.Delete(wert);
                            if (feedback)
                            {
                                if (idict.GetType().ToString().Equals("HashTabQuadProb") || idict.GetType().ToString().Equals("HashTabSepChain"))
                                {
                                    Console.WriteLine("Der Schlüssel {0} wurde gelöscht", wert);
                                }
                                else
                                {
                                    Console.WriteLine("Die Zahl {0} wurde gelöscht", wert);
                                }
                            }
                            else
                            if (idict.GetType().ToString().Equals("HashTabQuadProb") || idict.GetType().ToString().Equals("HashTabSepChain"))
                            {
                                Console.WriteLine("Der Schlüssel {0} wurde nicht gefunden", wert);
                            }
                            else
                            {
                                Console.WriteLine("Die Zahl {0} wurde nicht gefunden", wert);
                            }
                        }
                        break;

                    //Aktion Print
                    case "p":
                    case "P":
                        Console.WriteLine("Sie haben Print ausgewählt");
                        idict.Print();
                        break;

                    //Aktion Zurück
                    case "z":
                    case "Z":
                        Console.WriteLine("Sie haben Zurück ausgewählt");
                        agieren = false;
                        break;

                    default:
                        Console.WriteLine("Eingabe ist nicht gültig");
                        break;
                    }
                } while (agieren);
            }
        }
示例#13
0
        static void Start(string[] args)
        {
            Console.OutputEncoding = Encoding.Unicode;
            ConsoleKeyInfo input;
            ConsoleKeyInfo input2;
            ConsoleKeyInfo CaseInput;
            ConsoleKeyInfo input3;


            while (true) // Outer Loop - Dictionary
            {
                Console.Clear();
                Banner.PrintBanner();
                Banner.PrintDicSuggestions();
                input = Console.ReadKey();
                if (input.Key == ConsoleKey.D1)
                {
                    do // Array decision which dictionary
                    {
                        Console.Clear();
                        Banner.Printbanner1();
                        Banner.PrintTypeSuggestion();
                        IDictionary    array;
                        ConsoleKeyInfo type = Console.ReadKey();
                        if (type.Key == ConsoleKey.D1)
                        {
                            array = new MultiSetSortedArray();
                        }
                        else if (type.Key == ConsoleKey.D2)
                        {
                            array = new MultiSetUnsortedArray();
                        }
                        else if (type.Key == ConsoleKey.D3)
                        {
                            array = new SetSortedArray();
                        }
                        else if (type.Key == ConsoleKey.D4)
                        {
                            array = new SetUnsortedArray();
                        }
                        else if ((type.Key == ConsoleKey.Backspace) || (type.Key == ConsoleKey.Escape))
                        {
                            break;
                        }
                        else
                        {
                            Console.WriteLine();
                            Console.WriteLine("input not accepted try again");
                            Console.ReadKey();
                            continue;
                        }
                        do // Inner Loop Array
                        {
                            Console.Clear();
                            Banner.Printbanner1();
                            Banner.PrintOperationSuggestions();
                            input2 = Console.ReadKey();
                            if (input2.Key == ConsoleKey.S)
                            {
                                Banner.PrintSearchSuggestions();
                                int inputint;
                                try
                                {
                                    inputint = Convert.ToInt32(Console.ReadLine());
                                }
                                catch (Exception)
                                {
                                    Console.WriteLine("Input is not an Integer, press any key and repeat");
                                    Console.ReadKey();
                                    continue;
                                }

                                bool success = array.Search(inputint);
                                if (success == true)
                                {
                                    Console.WriteLine("found your integer!");
                                }
                                else
                                {
                                    Console.WriteLine("Did not find your integer");
                                }
                            }
                            else if (input2.Key == ConsoleKey.I)
                            {
                                Banner.PrintInsertSuggestions();
                                Console.WriteLine();
                                int inputint;
                                try
                                {
                                    inputint = Convert.ToInt32(Console.ReadLine());
                                }
                                catch (Exception)
                                {
                                    Console.WriteLine("Input is not an Integer, press any key and repeat");
                                    Console.ReadKey();
                                    continue;
                                }
                                bool success = array.Insert(inputint);
                                if (success == true)
                                {
                                    Console.WriteLine("successfully inserted " + inputint);
                                }
                                else
                                {
                                    Console.WriteLine("could not insert" + inputint);
                                }
                            }
                            else if (input2.Key == ConsoleKey.D)
                            {
                                Banner.PrintDeleteSuggestions();
                                Console.WriteLine();
                                int inputint;
                                try
                                {
                                    inputint = Convert.ToInt32(Console.ReadLine());
                                }
                                catch (Exception)
                                {
                                    Console.WriteLine("Input is not an Integer, press any key and repeat");
                                    Console.ReadKey();
                                    continue;
                                }
                                try
                                {
                                    bool success = array.Delete(inputint);
                                    if (success == true)
                                    {
                                        Console.WriteLine("successfully deleted " + inputint);
                                    }
                                    else
                                    {
                                        Console.WriteLine("could not delete" + inputint);
                                    }
                                }
                                catch (Exception)
                                {
                                    Console.WriteLine("Array Empty");
                                }
                            }
                            else if (input2.Key == ConsoleKey.P)
                            {
                                Banner.PrintPrintMessage();
                                Console.WriteLine();
                                array.Print();
                            }
                            Console.WriteLine("press any key to continue");
                            Console.ReadKey();
                        } while (input2.Key != ConsoleKey.Backspace);
                    }while (input.Key != ConsoleKey.Backspace);
                }
                if (input.Key == ConsoleKey.D2)
                {
                    do // Lists decision which dictionary
                    {
                        Console.Clear();
                        Banner.Printbanner2();
                        Banner.PrintTypeSuggestion();
                        IDictionary    list;
                        ConsoleKeyInfo type = Console.ReadKey();
                        if (type.Key == ConsoleKey.D1)
                        {
                            list = new MultiSetSortedLinkedList();
                        }
                        else if (type.Key == ConsoleKey.D2)
                        {
                            list = new MultiSetUnsortedLinkedList();
                        }
                        else if (type.Key == ConsoleKey.D3)
                        {
                            list = new SetSortedLinkedList();
                        }
                        else if (type.Key == ConsoleKey.D4)
                        {
                            list = new SetUnsortedLinkedList();
                        }
                        else if ((type.Key == ConsoleKey.Backspace) || (type.Key == ConsoleKey.Escape))
                        {
                            break;
                        }
                        else
                        {
                            Console.WriteLine();
                            Console.WriteLine("input not accepted try again");
                            Console.ReadKey();
                            continue;
                        }
                        do // Inner Loop Array
                        {
                            Console.Clear();
                            Banner.Printbanner2();
                            Banner.PrintOperationSuggestions();
                            input2 = Console.ReadKey();
                            if (input2.Key == ConsoleKey.S)
                            {
                                Banner.PrintSearchSuggestions();
                                Console.WriteLine();
                                int inputint;
                                try
                                {
                                    inputint = Convert.ToInt32(Console.ReadLine());
                                }
                                catch (Exception)
                                {
                                    Console.WriteLine("Input is not an Integer, press any key and repeat");
                                    Console.ReadKey();
                                    continue;
                                }
                                bool success = list.Search(inputint);
                                if (success == true)
                                {
                                    Console.WriteLine("found your integer!");
                                }
                                else
                                {
                                    Console.WriteLine("Did not find your integer");
                                }
                            }
                            else if (input2.Key == ConsoleKey.I)
                            {
                                Banner.PrintInsertSuggestions();
                                Console.WriteLine();
                                int inputint;
                                try
                                {
                                    inputint = Convert.ToInt32(Console.ReadLine());
                                }
                                catch (Exception)
                                {
                                    Console.WriteLine("Input is not an Integer, press any key and repeat");
                                    Console.ReadKey();
                                    continue;
                                }
                                bool success = list.Insert(inputint);
                                if (success == true)
                                {
                                    Console.WriteLine("successfully inserted " + inputint);
                                }
                                else
                                {
                                    Console.WriteLine("could not insert" + inputint);
                                }
                            }
                            else if (input2.Key == ConsoleKey.D)
                            {
                                Banner.PrintDeleteSuggestions();
                                Console.WriteLine();
                                int inputint;
                                try
                                {
                                    inputint = Convert.ToInt32(Console.ReadLine());
                                }
                                catch (Exception)
                                {
                                    Console.WriteLine("Input is not an Integer, press any key and repeat");
                                    Console.ReadKey();
                                    continue;
                                }
                                bool success = list.Delete(inputint);
                                if (success == true)
                                {
                                    Console.WriteLine("successfully deleted " + inputint);
                                }
                                else
                                {
                                    Console.WriteLine("could not delete" + inputint);
                                }
                            }
                            else if (input2.Key == ConsoleKey.P)
                            {
                                Console.WriteLine();
                                Banner.PrintPrintMessage();
                                Console.WriteLine();
                                list.Print();
                            }
                            Console.WriteLine("press any key to continue");
                            Console.ReadKey();
                        } while (input2.Key != ConsoleKey.Backspace);
                    }while (input.Key != ConsoleKey.Backspace);
                }
                if (input.Key == ConsoleKey.D3)
                {
                    do // BinaryTree decision which dictionary
                    {
                        IDictionary bintree = new BinSearchTree();

                        do // Inner Loop BinaryTree
                        {
                            Console.Clear();
                            Banner.Printbanner3();
                            Banner.PrintOperationSuggestions();
                            input2 = Console.ReadKey();
                            if (input2.Key == ConsoleKey.S)
                            {
                                Banner.PrintSearchSuggestions();
                                Console.WriteLine();
                                int inputint;
                                try
                                {
                                    inputint = Convert.ToInt32(Console.ReadLine());
                                }
                                catch (Exception)
                                {
                                    Console.WriteLine("Input is not an Integer, press any key and repeat");
                                    Console.ReadKey();
                                    continue;
                                }
                                bool success = bintree.Search(inputint);
                                if (success == true)
                                {
                                    Console.WriteLine("found your integer!");
                                }
                                else
                                {
                                    Console.WriteLine("Did not find your integer");
                                }
                            }
                            else if (input2.Key == ConsoleKey.I)
                            {
                                Banner.PrintInsertSuggestions();
                                Console.WriteLine();
                                int inputint;
                                try
                                {
                                    inputint = Convert.ToInt32(Console.ReadLine());
                                }
                                catch (Exception)
                                {
                                    Console.WriteLine("Input is not an Integer, press any key and repeat");
                                    Console.ReadKey();
                                    continue;
                                }
                                bool success = bintree.Insert(inputint);
                                if (success == true)
                                {
                                    Console.WriteLine("successfully inserted " + inputint);
                                }
                                else
                                {
                                    Console.WriteLine("could not insert" + inputint);
                                }
                            }
                            else if (input2.Key == ConsoleKey.D)
                            {
                                Banner.PrintDeleteSuggestions();
                                Console.WriteLine();
                                int inputint;
                                try
                                {
                                    inputint = Convert.ToInt32(Console.ReadLine());
                                }
                                catch (Exception)
                                {
                                    Console.WriteLine("Input is not an Integer, press any key and repeat");
                                    Console.ReadKey();
                                    continue;
                                }
                                bool success = bintree.Delete(inputint);
                                if (success == true)
                                {
                                    Console.WriteLine("successfully deleted " + inputint);
                                }
                                else
                                {
                                    Console.WriteLine("could not delete" + inputint);
                                }
                            }
                            else if (input2.Key == ConsoleKey.P)
                            {
                                Console.WriteLine();
                                Banner.PrintPrintMessage();
                                Console.WriteLine();
                                bintree.Print();
                            }
                            Console.WriteLine("press any key to continue");
                            Console.ReadKey();
                        } while (input2.Key != ConsoleKey.Backspace);
                        Console.WriteLine("if you want to go back, press Backspace");
                        input = Console.ReadKey();
                    }while (input.Key != ConsoleKey.Backspace);
                }
                if (input.Key == ConsoleKey.D4)
                {
                    IDictionary avltree = new AVLTree();

                    do // Inner Loop AVL
                    {
                        Console.Clear();
                        Banner.Printbanner4();
                        Banner.PrintOperationSuggestions();
                        input2 = Console.ReadKey();
                        if (input2.Key == ConsoleKey.S)
                        {
                            Banner.PrintSearchSuggestions();
                            Console.WriteLine();
                            int inputint;
                            try
                            {
                                inputint = Convert.ToInt32(Console.ReadLine());
                            }
                            catch (Exception)
                            {
                                Console.WriteLine("Input is not an Integer, press any key and repeat");
                                Console.ReadKey();
                                continue;
                            }
                            bool success = avltree.Search(inputint);
                            if (success == true)
                            {
                                Console.WriteLine("found your integer!");
                            }
                            else
                            {
                                Console.WriteLine("Did not find your integer");
                            }
                        }
                        else if (input2.Key == ConsoleKey.I)
                        {
                            Banner.PrintInsertSuggestions();
                            Console.WriteLine();
                            int inputint;
                            try
                            {
                                inputint = Convert.ToInt32(Console.ReadLine());
                            }
                            catch (Exception)
                            {
                                Console.WriteLine("Input is not an Integer, press any key and repeat");
                                Console.ReadKey();
                                continue;
                            }
                            bool success = avltree.Insert(inputint);
                            if (success == true)
                            {
                                Console.WriteLine("successfully inserted " + inputint);
                            }
                            else
                            {
                                Console.WriteLine("could not insert" + inputint);
                            }
                        }
                        else if (input2.Key == ConsoleKey.D)
                        {
                            Banner.PrintDeleteSuggestions();
                            Console.WriteLine();
                            int inputint;
                            try
                            {
                                inputint = Convert.ToInt32(Console.ReadLine());
                            }
                            catch (Exception)
                            {
                                Console.WriteLine("Input is not an Integer, press any key and repeat");
                                Console.ReadKey();
                                continue;
                            }
                            bool success = avltree.Delete(inputint);
                            if (success == true)
                            {
                                Console.WriteLine("successfully deleted " + inputint);
                            }
                            else
                            {
                                Console.WriteLine("could not delete" + inputint);
                            }
                        }
                        else if (input2.Key == ConsoleKey.P)
                        {
                            Console.WriteLine();
                            Banner.PrintPrintMessage();
                            Console.WriteLine();
                            avltree.Print();
                        }
                        Console.WriteLine("press any key to continue");
                        Console.ReadKey();
                    } while (input2.Key != ConsoleKey.Backspace);
                }
                if (input.Key == ConsoleKey.D5)
                {
                    Treap treap = new Treap();
                    do // Inner Loop Treap
                    {
                        Console.Clear();
                        Banner.Printbanner5();
                        Banner.PrintOperationSuggestions();
                        input2 = Console.ReadKey();
                        if (input2.Key == ConsoleKey.S)
                        {
                            Banner.PrintSearchSuggestions();
                            Console.WriteLine();
                            int inputint;
                            try
                            {
                                inputint = Convert.ToInt32(Console.ReadLine());
                            }
                            catch (Exception)
                            {
                                Console.WriteLine("Input is not an Integer, press any key and repeat");
                                Console.ReadKey();
                                continue;
                            }
                            bool success = treap.Search(inputint);
                            if (success == true)
                            {
                                Console.WriteLine("found your integer!");
                            }
                            else
                            {
                                Console.WriteLine("Did not find your integer");
                            }
                        }
                        else if (input2.Key == ConsoleKey.I)
                        {
                            while (true) //1 rng , 2 own
                            {
                                Console.WriteLine();
                                Console.WriteLine("Press 1 for random Priorities or 2 for own Priorities");
                                CaseInput = Console.ReadKey();
                                if (CaseInput.Key != ConsoleKey.D1 && CaseInput.Key != ConsoleKey.D2)
                                {
                                    Console.WriteLine("you did not press 1 or 2, press any key and try again");
                                    Console.ReadKey();
                                    continue;
                                }
                                else
                                {
                                    break;
                                }
                            }
                            while (true)
                            {
                                Console.Clear();
                                Banner.Printbanner5();
                                Banner.PrintInsertSuggestions();
                                Console.WriteLine();
                                int inputint;
                                try
                                {
                                    inputint = Convert.ToInt32(Console.ReadLine());
                                }
                                catch (Exception)
                                {
                                    Console.WriteLine("Input is not an Integer, press any key and repeat");
                                    Console.ReadKey();
                                    continue;
                                }

                                bool success = false;
                                if (CaseInput.Key == ConsoleKey.D1)
                                {
                                    success = treap.Insert(inputint);
                                }
                                else
                                {
                                    int inputprio;
                                    while (true)
                                    {
                                        Console.WriteLine("enter your priority as Integer: ");
                                        try
                                        {
                                            inputprio = Convert.ToInt32(Console.ReadLine());
                                        }
                                        catch (Exception)
                                        {
                                            Console.WriteLine("Input is not an Integer, press any key and repeat");
                                            Console.ReadKey();
                                            continue;
                                        }
                                        break;
                                    }
                                    success = treap.Insert(inputint, inputprio);
                                }

                                if (success == true)
                                {
                                    Console.WriteLine("successfully inserted " + inputint);
                                }
                                else
                                {
                                    Console.WriteLine("could not insert" + inputint);
                                }
                                Console.WriteLine("press Backspace to escape loop");
                                input3 = Console.ReadKey();
                                if (input3.Key == ConsoleKey.Backspace)
                                {
                                    break;
                                }
                            }
                        }
                        else if (input2.Key == ConsoleKey.D)
                        {
                            Banner.PrintDeleteSuggestions();
                            Console.WriteLine();
                            int inputint;
                            try
                            {
                                inputint = Convert.ToInt32(Console.ReadLine());
                            }
                            catch (Exception)
                            {
                                Console.WriteLine("Input is not an Integer, press any key and repeat");
                                Console.ReadKey();
                                continue;
                            }
                            bool success = treap.Delete(inputint);
                            if (success == true)
                            {
                                Console.WriteLine("successfully deleted " + inputint);
                            }
                            else
                            {
                                Console.WriteLine("could not delete" + inputint);
                            }
                        }
                        else if (input2.Key == ConsoleKey.P)
                        {
                            Console.WriteLine();
                            Banner.PrintPrintMessage();
                            Console.WriteLine();
                            treap.Print();
                        }
                        Console.WriteLine("press any key to continue");
                        Console.ReadKey();
                    } while (input2.Key != ConsoleKey.Backspace);
                }
                if (input.Key == ConsoleKey.D6)
                {
                    do // Inner Loop Hash
                    {
                        Console.Clear();
                        Banner.Printbanner6();
                        Banner.PrintHashType();
                        IDictionary    hashstuff;
                        ConsoleKeyInfo type = Console.ReadKey();
                        if (type.Key == ConsoleKey.D1)
                        {
                            hashstuff = new HashTabQuadProb();
                        }
                        else if (type.Key == ConsoleKey.D2)
                        {
                            hashstuff = new HashTabSepChain();
                        }
                        else if (type.Key == ConsoleKey.Backspace)
                        {
                            break;
                        }
                        else
                        {
                            Console.WriteLine("Input not accepted");
                            Console.WriteLine("Press any key to try again");
                            Console.ReadKey();
                            continue;
                        }
                        do
                        {
                            Console.Clear();
                            Banner.Printbanner6();
                            Banner.PrintOperationSuggestions();
                            input2 = Console.ReadKey();
                            if (input2.Key == ConsoleKey.S)
                            {
                                Banner.PrintSearchSuggestions();
                                Console.WriteLine();
                                int inputint;
                                try
                                {
                                    inputint = Convert.ToInt32(Console.ReadLine());
                                }
                                catch (Exception)
                                {
                                    Console.WriteLine("Input is not an Integer, press any key and repeat");
                                    Console.ReadKey();
                                    continue;
                                }
                                bool success = hashstuff.Search(inputint);
                                if (success == true)
                                {
                                    Console.WriteLine("found your integer!");
                                }
                                else
                                {
                                    Console.WriteLine("Did not find your integer");
                                }
                            }
                            else if (input2.Key == ConsoleKey.I)
                            {
                                Banner.PrintInsertSuggestions();
                                Console.WriteLine();
                                int inputint;
                                try
                                {
                                    inputint = Convert.ToInt32(Console.ReadLine());
                                }
                                catch (Exception)
                                {
                                    Console.WriteLine("Input is not an Integer, press any key and repeat");
                                    Console.ReadKey();
                                    continue;
                                }
                                bool success = hashstuff.Insert(inputint);
                                if (success == true)
                                {
                                    Console.WriteLine("successfully inserted " + inputint);
                                }
                                else
                                {
                                    Console.WriteLine("could not insert" + inputint);
                                }
                            }
                            else if (input2.Key == ConsoleKey.D)
                            {
                                Banner.PrintDeleteSuggestions();
                                Console.WriteLine();
                                int inputint;
                                try
                                {
                                    inputint = Convert.ToInt32(Console.ReadLine());
                                }
                                catch (Exception)
                                {
                                    Console.WriteLine("Input is not an Integer, press any key and repeat");
                                    Console.ReadKey();
                                    continue;
                                }
                                bool success = hashstuff.Delete(inputint);
                                if (success == true)
                                {
                                    Console.WriteLine("successfully deleted " + inputint);
                                }
                                else
                                {
                                    Console.WriteLine("could not delete" + inputint);
                                }
                            }
                            else if (input2.Key == ConsoleKey.P)
                            {
                                Console.WriteLine();
                                Banner.PrintPrintMessage();
                                Console.WriteLine();
                                hashstuff.Print();
                            }
                            Console.WriteLine();
                            Console.ReadKey();
                        } while (input2.Key != ConsoleKey.Backspace);
                        ////
                    } while (input.Key != ConsoleKey.Backspace);
                }


                //input = Console.ReadKey();
            }
        }