Giter Site home page Giter Site logo

assignment1's Introduction

Assignment1

For Q1, I am using an array which holds all the occurences of all chars that appear in the first string. Say char 'a' appears twice, then v[0] is 2. 0 is the ascii code of the given char 'a' minus 'a'. Then for the second iteration through the second string I check whether v[character] is != 0 (is present). I added a method checkStr(s1, s2) that validates the given strings (checks if they contain letters only). It has an overall complexity of O(n).

For Q2, I've implemented a singly linked list and the operations associated with it - size for retrieving its size and get that returns the element at the given position. To solve it, I just call get(size_of_list - k) to return the k-th element to the last. At the moment I am thinking about finding a way to stop using size since I'm already iterating through the list when I try to find that specific element. The overall complexity is that of find which is done in linear time O(n).

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.