Code Monkey home page Code Monkey logo

cs260_p3's Introduction

CS260_P3

Programming assignment 3 for CS260

Assign yourself to 40 points worth of work. Don't take what has been claimed already. Make use of the folder structure that is in place. Update the readme with how to run your code. Python or C++ doesn't matter to me, just has to work.

Problem 1: The python file has all the program coded and the output of the file will give the answer of the best constants and explanation. Just type: python problem1.py
The output will show the testing data. Our example data and tables of running it are shown as follows: INSERTION Key Value Running Time Key1 3 1 Key2 4 1 Deletion - delete Key1 Key Value Running Time Key1 1 Key2 4 1

Problem 4: The supplement files for problem 4 are AliceInWonderland.txt and list_array.py. Make sure they have the same path as problem4.py does. First type: python problem4.py The output will explain how the code works and at the end of explanation, it will ask you to input the file name you want to evaluate the tries size. After you entered the name, press return button, and the size of the file will be shown in the next line. For example, our text file is named "AliceInWonderland.txt". After you ran the program, you will see: ........ (explanation), The size of the trie of Alice In Wonderland is: you can just input : AliceInWonderland.txt and press enter Then you will the tries size.

Problem 5: This uses the Dijkstra algorithm on problem number six of review 2 using the adjacency representation of the graph. The file, Dijkstra_AM.cpp, when run will print out the final vector D[], P[], and S[] which match that answers provided in the Review 2 solutions. This Fills all nodes not connected to one another/themselves with the INF infinity constant I defined as 100 in the adjacency matrix.

Problem 6: This uses the Dijkstra algorithm but in a more efficient manner, with a graph represented by an array of Nodes with adjacency lists and a partially ordered tree corresponding to the edge lengths. When run this program, Dijkstra_PoT, will print out the distances D[] for the minimal spanning graph. Note here, node 1 has distance 0 from itself unlike the previous implementation which has it at 100 (Infinity constant).

Problem 8: This implements a depth first search printing out a numbered list. Simply run the p8.py program within the python folder. This has a sample graph that is depicted in Figure 6.28 of the class textbook.

Problem 9: This implements the two recommended FFT algorithms and compares the output to the numpy implementation of fft, which is known to work. This program can be found in the python folder, simply run FFT.py. This output deviation between implemented algorithms and numpy's. Depending on the computer this may take a little bit to run. The results initially show deviation on the scale of 10^-28, which is small enough to be ignored.

cs260_p3's People

Watchers

 avatar  avatar  avatar  avatar

cs260_p3's Issues

Problem 9

  1. (30 points) Fast Fourier Transform in two versions ([W] 2.5): dyadic size ([W] p.53) and any size ([W] p.55). Verify correctness of your implementations by comparing the results of your program with the results obtained with FFT's of standard mathematical packages.
    
    Symbol [W] refers to the book Algorithms and Complexity by Herbert Wilf.

Problem 5

  1.  (10 points) Dijkstra's shortest paths algorithm (6.3) with the adjacency matrix as the representation of the graph. Test your implementation on the graph of problem 6 of review 2.
    

Problem 7

  1. (10 points) Floyd's algorithm (6.4) with the option of recovering the paths. Test your implementation on the graph of problem 6 of review 2.
    

Problem 4

  1. (20 points) Trie (5.3) with a list representation for trie nodes (pages 167-168). Store the strings of the document Alice in Wonderland in your trie by iterating the INSERT operation and print out the size of the resulting trie (provide the exact definition of size that you use in your count).
    

Problem 3

  1.  (20 points) Dictionary ADT with BST's (5.1-5.2, figs 5.2-5.5). Verify experimentally that the average number of nodes on the path from the root to another node, in a random BST obtained by an iteration of INSERT operation is O(log2 n), where n is the number of items inserted into an initially empty BST. Assume that all permutations of elements are equally probable. It is recommended that you use library generators of random permutations.
    

Problem 8

  1. (10 points) Depth-first search algorithm (6.5) together with depth-first numbering of nodes. Test your algorithm on the graph of fig. 6.38, page 226.
    

Problem 6

  1. (30 points) Dijkstra's shortest paths algorithm (6.3) with a partially ordered tree as a priority queue and linked adjacency lists as the representation of the graph. Test your implementation on the graph of problem 6 of review 2.
    
    An implementation in C is described in section 9.8 of our CS 270 textbook Foundations of Computer Science by Alfred Aho and Jeffrey Ullman.
    book chapters: http://infolab.stanford.edu/~ullman/focs.html
    C code: http://infolab.stanford.edu/~ullman/fcsc-figures.html

Problem 1

  1. (20 points) For Dictionary ADT implemented with open hash tables the average number of probes required to make either a deletion or an insertion is O(1+a). Find best numerical constants for deletion and insertion.
    

Problem 2

  1. (20 points) For Dictionary ADT implemented with closed hash tables and the linear hashing as the rehash strategy the average number of probes required to make a deletion is approximately equal to (1+1/(1-a))/2 and the average number of probes required to make an insertion is approximately equal to (1+1/(1-a)2)/2.
    

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.