Exemple #1
0
        public bool Insert(int element)
        {
            int        heap = Convert.ToInt32((Console.ReadLine()));
            InfoReturn res  = base.Insert(data, new TreapElement(element, heap));

            if (res.success)
            {
                data = (TreapElement)res.newRoot;
            }

            DownHeap(element);

            return(res.success);
        }
Exemple #2
0
        public bool Delete(int element)
        {
            // Pruefen, ob Element Exist
            if (!base.Search(data, element)) //Element nicht gefunden
            {
                return(false);
            }

            // Element zu Blatt machen
            UpHeap(element);

            // Element loeschen
            InfoReturn res = base.Delete(data, element);

            if (res.success)
            {
                data = (TreapElement)res.newRoot;
            }

            return(res.success);
        }