data-structures

Particle Trajectory, to learn classes and data structures

Particle Trajectory, to learn classes and data structures Question: So the task is supposed to be done in multiply steps. So we are given a class Particles, that we have to define. It is supposed to have multiply methods, and here is where i meet my first struggle. Create a class called Particle that has …

Total answers: 1

Finding Existence of a Set From Combined Values of a Hashmap

Finding Existence of a Set From Combined Values of a Hashmap Question: Given string-list P of len(P) employees. A training session can be scheduled on 2 of 10 potential days, the days represented by 0-9. Each employee has given a string which consists of the numbers 0-9 with no spaces. These preferences are combined into …

Total answers: 1

Make set keep order of a tuple

Make set keep order of a tuple Question: In the code below, how can I use keep using set to have unique values, but also make set keep the order of how the filters are typed in? >>> filters = (‘f1’, ‘f2’) >>> set((*filters, ‘f3’)) {‘f1’, ‘f3’, ‘f2’} # expected: {‘f1’, ‘f2’, ‘f3’} Asked By: …

Total answers: 2

create Linkedlist from list

create Linkedlist from list Question: Can anyone help me understand why I get this error ? I design a Linkedlist Class like this where I want to create a linkedlist from an array: class Node: def __init__(self, val, next=None): self.val = val self.next = next class LinkedList: def __init__(self, head=None): self.head = head def arrayToLL(X): …

Total answers: 3

How do I make this function automatic, it clearly has a pattern

How do I make this function automatic, it clearly has a pattern Question: def populate_kids(self, arr, used_Indices): for a in self.children: a.get_all_jumps(arr, used_Indices) for a in self.children: for b in a.children: b.get_all_jumps(arr, used_Indices) for a in self.children: for b in a.children: for c in b.children: c.get_all_jumps(arr, used_Indices) for a in self.children: for b in a.children: …

Total answers: 2

How to reorder two lists of different size based on one list?

How to reorder two lists of different size based on one list? Question: Given two different lists which share elements in common and have different size, how to reorder the second list based on the order of the elements of the first one? For example: For: a = [‘a’, ‘b’, ‘e’, ‘z’, ‘f’] b = …

Total answers: 4

Pros/cons of defining a graph as nested node objects versus a dictionary?

Pros/cons of defining a graph as nested node objects versus a dictionary? Question: I am practicing a couple algorithms (DFS, BFS). To set up the practice examples, I need to make a graph with vertices and edges. I have seen two approaches – defining an array of vertices and an array of edges, and then …

Total answers: 1

Get a element from list, from pair of 3

Get a element from list, from pair of 3 Question: Hello I have a list in which elemnets are in pair of 3 list given below, labels = [”, ”, ‘5000’,”, ‘2’, ”,”, ”, ‘1000’,’mm-dd-yy’, ”, ”,”, ”, ’15’,’dd/mm/yy’, ”, ”, ”, ‘3’, ”,”, ”, ‘200’,”, ‘2’, ”,’mm-dd-yy’, ”, ”,”, ”, ”,”, ”, ”] in …

Total answers: 3

Why does my while loop calculate incorrect value of the string?

Why does my while loop calculate incorrect value of the string? Question: I am trying to find greatest length of a word from the string return it by using values of each letter from alphabets by assigning each letter it’s value as per it’s rank . So for example For a string s = ‘abcd …

Total answers: 3