Motivating Data Structures with Caching Internet Stock Data David B. Sher Math/Stat/CMP Department, Nassau Community College Garden City NY 11530 USA 011-516-572-7387 sherd@ncc.edu ABSTRACT Caching internet data is an application that illustrates data structure speed. I have developed a sequence of assignments for teaching about lists, hash tables and trees using caches for internet sourced stock prices. 2. Internet Application Categories and Subject Descriptors E.1 [Data Structures] Lists,Stacks and Queues, and F.2.2 [Nonnumerical Algorithms and Problems] Sorting and Searching, General Terms: Algorithms, Performance, Design, Theory.. Keywords: Analysis of Algorithms, Data Structures, Computer ScienceEducation 1. INTRODUCTION The typical data structures course (CS103 in the ACM Computer Science Curriculum [1]) introduces properties of data structures, particularly data structure best worst and average case speed. The purpose of programming projects in data structures is to illustrate data structure speed for differing data set sizes. A cache is particularly suitable for studying speed based on size because caches change size automatically. Caches improve the performance of many practical programs. Until now, I gave assignments that were largely abstract on this topic. For example, a typical assignment would: ¢ Read a list of words from a file. ¢ Store them in an unsorted linked list, sorted linked list, hash table, search tree and balanced search tree. ¢ Read words from a second file. ¢ Find out for each word in the second file how long each search took, whether each search was successful, how long the best, worst, and average search took for each data structure. A better assignment would have an apparent connection to real world programs but still illustrate the same concepts. This led me to memory caching for internet data. A cache stores data that otherwise would require a long time to access. In our application, the cache rapidly accesses historical stock prices originally from the internet. A cache is essentially a searchable dataset that can be implemented by any of these data structures: unsorted list, sorted list, hash table, search tree, balanced search tree, and a host of other tree based data structures. Hence, I developed a new set of data structures programming assignments based on an internet memory cache. Copyright is held by the author/owner(s). ITiCSE 06, June 26 28, 2006, Bologna, Italy. ACM 1-59593-055-8/06/0006. Figure 1 Internet Stock Data Application with Cache Statistics The internet application (figure 1) is designed to display historical stock data acquired from the finance.yahoo.com website. It was adapted from a tool I developed to teach mathematics students about mathematical modeling. 3. Internet Caching Assignments These are the internet caching assignments (in short): 1. Add a cache, implemented as an unsorted list, to the application. Report whether each stock data set is acquired from the cache or the internet in the cache output TextArea. 2. Add another cache implemented as a sorted list. Report for each cache whether each stock data set is acquired from the cache or internet, the number of comparisons needed for each cache and the total comparisons for all the data sets for each. 3. Add another cache implemented as a hash table. Report for each cache whether each stock data set is acquired from the cache or internet, the number of comparisons needed for each cache and the minimum, maximum, and average number of comparisons for all the data sets. 4. Add another cache implemented as a search tree, otherwise same as previous. 5. Add another cache implemented as a balanced tree, otherwise same as previous. 4.
/lp/association-for-computing-machinery/motivating-data-structures-with-caching-internet-stock-data-IKf8nc2KB7