Coder Social home page Coder Social logo

datastructuresandalgorithms-assessment's Introduction

Data Structures and Algorithms

In the same files or different scripts code out the following functions, push to a github repo and submit it for grading.

Stacks:

Question 1: Implement a function is_balanced(expression) that takes a string containing parentheses, curly braces, and square brackets,and determines whether the expression is balanced.

An expression is considered balanced if each opening bracket has a corresponding closing bracket in the correct order.

sample input =

expression1 = "([]{})" expression2 = "([)]" print(is_balanced(expression1)) # Output: True print(is_balanced(expression2)) # Output: False

Sequences (Lists/Tuples):

Question 2: Write a function remove_duplicates(sequence) that takes a sequence (list or tuple) and returns a new sequence with duplicates removed while maintaining the original order of elements.

sample input =

input_sequence = [2, 3, 2, 4, 5, 3, 6, 7, 5] result = remove_duplicates(input_sequence) print(result) # Output: [2, 3, 4, 5, 6, 7]

Dictionaries:

Question 3: Implement a function word_frequency(sentence) that takes a sentence and returns a dictionary containing the frequency of each word in the sentence.

Ignore punctuation and consider words in a case-insensitive manner.

sample input =

sentence = "This is a test sentence. This sentence is a test." result = word_frequency(sentence) print(result)

datastructuresandalgorithms-assessment's People

Contributors

muthuieric avatar

Watchers

 avatar

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.