Skip to content

Instantly share code, notes, and snippets.

Assignment 6: Functions Practice

Questions

1. Write a function with the following specification:

Given an array of integers, returns indices of the two numbers such that they add up to a specific target.

The function does not return anything but instead modifies the out parameter returnArr.

@skydowx
skydowx / lab_1_a.py
Last active November 4, 2021 08:15
Intro to AI, section B. Lab 1, part A.
"""
### Task 1 (A):
Using a Python create a Class named "**Stack**".
The class should contain push and pop methods. The items to be stored
in the stack should be objects of the the class "**Node**". The definition for this
Node class is given below.
You're not allowed to use any libraries for this task.
"""
@skydowx
skydowx / lab_1_b.py
Last active November 2, 2021 06:52
Intro to AI, section B. Lab 1, part B.
"""
Lab: 1
Task: B
Your task is to implement a basic Queue in python in an OOP fashion.
Like stack, queue is a linear data structure that stores items in First In First Out (FIFO) manner. With a queue the least recently added item is removed first. A good example of queue is any queue of consumers for a resource where the consumer that came first is served first.
You Queue should have the following functions working for it:
-> Enqueue(item): Adds an item to the queue.
-> Dequeue(): Removes an item form the queue. The items are popped in the same order in whcih they are pushed
-> Front(): Get the fron item from queue.
-> Rear(): Get the last item from the queue.