Beispiel #1
0
        public void Execute()
        {
            SequentialSearchST <string, int> st = new SequentialSearchST <string, int>();

            //adding
            for (int i = 0; i < a.Length; i++)
            {
                // to Key we write Word, to Value we write Frequency
                if (!st.contains(a[i]))
                {
                    st.put(a[i], 1);
                }
                else
                {
                    st.put(a[i], st.get(a[i]) + 1);
                }
            }
            // search max frequent word
            string maxFrequentWord = " ";

            st.put(maxFrequentWord, 0);
            foreach (var val in st)
            {
                if (st.get(val) > st.get(maxFrequentWord))
                {
                    maxFrequentWord = val;
                }
            }
            Console.WriteLine("maxFrequentWord=" + maxFrequentWord + " maxFrequency " + st.get(maxFrequentWord));
            st.ConsoleDisplay();
        }
Beispiel #2
0
        public void Execute()
        {
            SequentialSearchST <string, int> st = new SequentialSearchST <string, int>();

            //adding
            for (int i = 0; i < a.Length; i++)
            {
                st.put(a[i], i);
            }
            if (st.contains("X"))
            {
                Console.WriteLine("Yes! COntains X");
            }
            st.ConsoleDisplay();
            st.delete("L");
            Console.WriteLine();
            st.ConsoleDisplay();
        }