Giter Site home page Giter Site logo

directorymanager's Issues

Dynamic length of node name

Instead of the current static allocation of node name, implement dynamic memory allocation (using heap memory).

  1. Accept a string of a predefined maximum length
  2. Pass the value of the length of the input as an argument to init_node
  3. Dynamically allocate memory on the heap and copy contents of a given input string onto the node
  4. Make sure to free this chunk of memory as well before the end of the program

Remove hashtables for nodes of type: "file"

Currently, all nodes have a hashtable linked for the child nodes.
Since nodes of type file do not contain child nodes, make the program memory efficient by removing the corresponding linked hashtable.

Need to implement a string parser

  • Implement a string parser that takes in a string with alphanumeric characters and '/'.
  • Separate the string into groups of characters using '/' as the delimiter
  • Make sure to append the null character '\0' to every word of the final list of words
  • Both array and linked list-based implementation would be valid for the final list of words

Hashtable for Alias

We'll need a hashtable to maintain the Aliases for O(1) finding.

  • Should take in two strings, an alias and a string that denotes the path. Use the Alias as the key to store the path.
  • Add insertion and finding features
  • Error handling when an alias is already used
  • Add rehashing feature (assume the size to rehash to, to be available)
  • Preferably use quadratic probing

Foundation tree structure

Create the functionality of a basic tree structure which will represent the directories

  • Each file/folder will be a node
  • Each node has a boolean to denote if it is a file or a folder
  • Should have a linked list of children
  • Store pointers to all children
  • Optional: Add useful metadata
  • Insertion of node, finding a child, traversing the tree should be implemented

Final FIND function

Implement a function named FIND

  • Implement searching all the files/directories with given prefix inside the current directory.
  • Take a prefix-string input for search.
  • Output all the files/directories with the given prefix.

Final ADD function

Implement a function named ADD

  • Implement the addition of a file/directory inside the current directory.
  • Take user input for type (file/directory) and name.

Final MOVE function

Implement a function named MOVE

  • Change the current directory to any directory by taking input the complete path to that directory.
  • Error handling should be done for incorrect paths.

Tree traversal given a path

  • Given a list of nodes, traverse the tree and return the pointer to the final destination node.
  • Return NULL if the path is invalid

Implementing hashtable for the children nodes

Currently, we have a linked list that stores the list of children to a given node.
Finding in the linked list would take us O(n) time where 'n' is the number of children to a given node.
This not only makes finding slow but it delays traversal.

So, implement a hashtable that:

  • Uses the path-name of the child node as the input to the hash function to come up with a hash value
  • Implement finding a child node to current node in O(1)
    • If found, return a pointer to the node.
    • If not, return NULL
  • Implement rehashing using the prime finder util

Final TELEPORT function

Implement a function named TELEPORT

  • Change the current directory to any directory by taking input the alias of that directory.
  • Error handling should be done for non-existing aliases.

Restructure "TreeNode"

  • To remove char name[NAME_SIZE] and bool isFile into a separate struct from struct treenode to make it easier to work with when changing to an array implementation of children.
  • This would require changing the fundamental functions written for linked lists as well.

Final ALIAS function

Implement a function named ALIAS

  • Implement saving a directory with an alias.
  • Take input the complete path to that directory and the alias.
  • Error handling should be done for incorrect path and for already-existing aliases.

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.