Data-structures Questions
Ad
What are some best practices for searching a binary tree?
I'm learning about binary trees in c and i wrote a function to search my tree which is a tree of strings. it works, however, it seg faults if the
Time compleity of dynamic arrays in C
When we consider dynamic arrays in java or python (list), the average time complexity is o(1) for appending an element and worst
Why is the address of pointer s the same as when we are accessing the first element of unnamed array?
If string is basically a pointer then how does it behave as an array? ie: you can use say: char *s = "david"
Insertion Sort for Singly Linked List in C
I'm trying to improve my knowledge on algorithms and data structures, so for the last 5-6 days i've been trying to implement different algorithms
Segmentation fault in C for Stack implementation using arrays with pointers
I have this code for stack implementation using arrays with pointers which performs lot of operations like push, peep, pop, destroy. i already
valgrind Invalid write of size 8 in a allocated memory
I am trying to add new node to my linked list, but it's gives memory error my struct and global vars: typedef struct word
Selecting best data structure for a 2-dimensional map that will shift the data
I need some help in the ways of implementing a faster way to do a full shift on a two-dimensional array. my problem is i have a 2
How many duplicate numbers repeat in array
I want to count how many time duplicate numbers repeat in list. i have written the code that only find the duplicate numbers in list but my
One or Two Primary Keys in Many-to-Many Table?
I have the following tables in my database that have a many-to-many relationship, which is expressed by a connecting table that has foreign keys
How do you represent music in a data structure?
How would you model a simple musical score for a single instrument written in regular standard notation? certainly there are plenty of libraries
Ad
Segmentation Fault error - binary search tree in C
I'm trying to build a binary search tree. inserting an integer using insert function (only using 1 to 100 for testing) and appending the result to
Create a tree from a file .txt in C
My problem is the following: i have to create a tree from a file .txt, this is an example of what is inside the file:
C error: expected declaration specifiers or '...' before '*' token
So i'm learning data structures and pretty much new to c. i am trying to make a function that accepts student id and the course number and the
Hash Functions and Tables of size of the form 2^p
While calculating the hash table bucket index from the hash code of a key, why do we avoid use of remainder after division (modulo) when the size
How can I find the error in this C program?
I am learning data structures and pretty much new to c. i can't figure out what's causing the error in this function: struct
How can I get a list of the differences between two JavaScript object graphs?
I want to be able to get a list of all differences between two javascript object graphs, with the property names and values where the deltas
Best way to retrieve K largest elements from large unsorted arrays?
I recently had a coding test during an interview. i was told: there is a large unsorted array of one million
Graph visualization library in JavaScript
I have a data structure that represents a directed graph, and i want to render that dynamically on an html page. these graphs will usually be
Why are entries in addition order in a .Net Dictionary?
I just saw this behaviour and i'm a bit surprised by it... if i add 3 or 4 elements to a dictionary, and then do a "for each" to get all
Array data structure in nodejs
I'm working on a nodejs project where i need to restructure an array of objects. below is the sample out put i get from database,
Find the most common elements in array of objects
[{ country: "us", languages: [ "en" ] }, { country: "be", languages: [
Ad
I am getting empty array when I try to upload multiple images to my backend
I have created an api in the backend which will store images to the database, i created a function for uploading the images but i get an empty
How do I dynamically allocate a struct but not it's attributes?
I'm a programming noob. i want to allocate a struct but since the size of my attributes are already defined, how would i use malloc() in this
Undo redo for a huge object
I have a requirement where the product needs to implement undo-redo functionality. currently i hold a huge object which comes from a
rearranging a string structure in python
I am cleaning multiple pdf files. and i have combined two dictionaries to get three outputs. the file name which is key, the
How to pass data from each activity to another?
I have 5 activities in my project, where one activity leads to another in the following manner: selection selecttype
Creating a data structure of integers and finding which component a given integer lies in
I have a set of 32 bit integers with which i will be making a data structure that will put these integers in different components ( like dsu ) the
How to traverse a trie to display all the words?
Here's my declaration of a trie in c++ using unordered_map class trie{ public: unordered_map<char,trie*>m; bool
Merge JSON objects to handle rendering duplicated info on React
After fetching data from an api on react, i have the following json data. then i use .map method to loop over each object and display
Python tree implementation not showing correct path
I tried implementing the following code. but according to logic, the path output for node "a" to "d" is displayed none, though the path can be
Alternative to nested documents in Firestore - looking for best practices?
I have some concerns about the structure for a firestore-based project, since directly nesting documents don't seem to be an option. to
Find the best way to implement a 'like' logic in firebase and flutter
I have a question. i develop a feature waht user allow to like a task. for example:
Ad
Problem with data structure in a post for Firebase in Swift
I am trying to create a post for firebase's database. the structure is a bit complex. the json format for the structure is this:
Is there a way to add a custom path subcollection in Firestore without the parent document being empty?
I'm creating a "deep" path scheme in firestore. (6 part path, 3 collections and 3 documents) something like
How to implement deque data structure in javascript?
I'm learning data structure with javascript and my focus now on how to implement deque? edite: from comments below
how do i update state in react for updating the value of an object inside an array using array.map function
The function handlefeetandinch updates the state using index while using array.map and passing the function which updates the state but the state
What is this data structure with default property and type-like object in JS?
I notice that in some js objects, they have properties with some special behaviours. for example, the model objects in sequelize, if i log a model
Output form ArrayMap equals to null
I'm writing a parser to print a file json on my mobile. i include an arraymap to save data received from the file. my problem is that when i have
CSV to Python Dictionary
For homework we have been asked to build a dictionary from csv (without importing csv or any other lib, only using built in python functions).
How to test a custom implementation of an AVL tree
I've implemented an avl tree in c++ and would like to stress test
Sum of n number inside array is x number and create subset of result
For example, if you have an array [20, 6, 7, 8, 50] and if i pass value 21 it should return [6,7,8] this sub array. note: the sum of number should
How to call a stored procedure that has several types in C# on .NET Core
I wrote a stored procedure that takes two types i created as parameters, called type1 and type2 : create
Binary search within BTree to improve performance
I'm reading through cormen et. al. again, specifically the chapter on btrees, and i am implementing one in c. however, i had a question about
Ad
Shifting values from one key to another key in python dictionary
I've the below dictionary (geojson): 'properties': { 'fill': '#ffffff', 'fill-opacity': 1, 'stroke': '#ffffff',
How to spread nested properties in Object?
I have this object below. i was wondering how i can select a specific item and update a property. for example. item 1 i want to add a task in the
Tree structure not building as expected
I'm trying to write a function to create a tree from a given starting directory. in other words, i choose a directory, and then the function maps
How to group/club elements in a 2D list based on the 1D elements belonging to another 2D list?
I'm new to python and i have a question on involving data structures and algorithms(which are essential skills that a programmer should have)
How to flatten my data from nested references?
Hey guys i need some help to structure some data, but i would need some insights to do this as performant as possible. i have been losing my head
How to display all products by category and sub-category wise in a single screen?
I have a list of products in my database as follows: database
Length of sequences of numbers greater than x in a list
I need to retrieve the length of sequences, which numbers are all greater than an arbitrary chosen value x (some
Create nested array having an element path array
I have this array: var array ={data: [ { id:'1', name:'first', data:[] }]} and i
Generate json object from variables and insert into another json object
This question is purely syntax. i'm trying to insert a generated json object into another json object. let's say my json looks like
Sorting a Linked List that contains two data in a Node
Class node : def __init__(self, newdata=none, newartist=none, nextnode=none): self.data = newdata self.artist =
How to create the following data structure in a NoSQL environment
Intro i have a firestore database similar to a social media db, with 3 collections users, events, and eventupdates. my goal
Ad
How can I call only the second string in this Map Double Double?
This is how i pull data from google sheets: map<double, double> m = (await sheet.values.map.column(3, fromrow: 2)).map((
Python, heapq, How to efficiently modify the minimum element in heapq?
I am using heapq in python 3.7 i have two questions about heapq: i don't know how to keep the heap invariant efficiently if
Is Time complexity O(n) or O(n^2)?
I feel that the time complexity of this js function i wrote is o(n) but at the same time it feels like its o(n^2). what's the correct time
merging two elements from two list in random
I am trying to randomly match two elements from list and tuple. my goal is to create a string with 1 to 1 match. below is the ideal code i
What is the best way to store 'likes' in Firebase?
The structure of my firebase database is: users: [ {userid: {...}}, // private data for specific user ... ], likes: [ //
What is the most efficient way of comparing two sets?
In python3, what is the least time-consuming way of comparing two sets elements(whether they
inserting a node at tail python
I'm trying to insert a node at the tail but my list keeps just saving the last value if i try to insert 1,5,7 at the head and 9 at tail..i
Efficient way to check whether a graph has become disconnected?
Using a disjoint set forest, we can efficiently
Is insertion of heapq is faster than insertion of bisect?
I have a question about bisect and heapq. first i will show you 2 versions of code and then ask question about it. version
Problems while zipping two lists as a dictionary?
I have the following lists: a = ['a', 'b', 'c', 'c'] b = ['2', '3', 2, 3] i am zipping them as follows in order
Structuring Firebase database like Snapchat
I've been working on a snapchat clone as a way to learn how to use firebase. i am currently stuck on how to best structure my data so that
Ad
How can I generate a list of lists of permutations
Let's say i have a list of pattern [2, 1] and given a length = 5. the pattern means that there are sets of 2 and
10000000000%10 returning 8 in Java
Q ) to reverse two linked lists, add them and return a reversed linked list of the sum`
Retrieving Map from List of Maps using for loop
I've created list of maps using the following list<map<object, string>> postmodel = new arraylist<>();
How to incorporate metadata into NLTK corpus for efficient processing
I have a folder of txt files and also a csv file with additional data like categories a particular txt document belongs to and the original source
How to make a listview table be zipped every 4
How to make a listview table be zipped every 4. items instead of 1 white 1 black.. i managed to do however with odd or even numbers here is the
How do i write a function in JavaScript that compares two trees defined by TreeNodes a and b?
I'm trying to write a javascript function that compares two binary trees defined by treenodes a and b and returns true if they are
Program Exits Unintentionally When Entering Elements in Array-Based Queue and Does not Continue to Compile the Rest of the Program
I am having this bug where my program unexpectedly exits after entering elements for my array-based queue. it is supposed to run like so:
Return Tree Set from function Java
I need to create a method public static treeset<string> getset(string s) in java that takes an inputted string and does the
Flutter & Firestore location-based queries & data structure
I am currently working on an app that will connect clients and craftsmen. right now i am structuring the database and thinking about possible
Given MxN Matrix, count number 0s whose row and column consists of only one ZERO
For example: input: //mxn matrix matrix = [ [ 0, 0, 1 ], [ 1, 1, 0 ], [ 0, 1, 1 ] ]
Python tree datatype add child operation results in recursive children
I have a tree generated at python and i just simply want to append a new child to a parent however, although the children of the child no is
Ad
Custom datastructure: Dictionary of dictionaries with cumulative value
Context i'm working on a python script that manipulates statistics provided by google relatively to installed apps from the play store.
Python: Write to CSV with multiple header rows
Context i am looking to export a dictionary which contains a list of dictionaries as the value of each key:value pair:
Deleting a node with two children in BST
I have implemented a binary search tree and it is working fine except for the case where i have to delete a node with two children. the following
how to find list of all words from a given array of characters
I am trying to solve a word puzzle with 5 alphabets, which can have 3 , 4 and 5 letter words . how should i write my algorithm to make this
Save the final value of a linked list to a variable in Java
I want to save the final value on a linkedlist of 5000000 integers by using an iterator. for this assignment, i need to traverse through the
Make a hierarchical tree from flat array of objects by field value
Need to convert an array like: [ {value: 'a', depth: 1, children: []}, {value: 'c', depth: 2, children: []}, {value: 'd',
How to find the top 10 words from a given string at any given point of time. Python
Lets say i have a string s and words are keep on adding to the string at any given point of time. now i have to maintain top 10
Firestore features and limitations on different data structure model
I have created app whose structure looks like this. current structure for one company only. let current = { products: {
How to create a fast autocomplete feature on the back-end
I'm quite new to data structures but i was trying to implement an efficient city lookup / city autocomplete feature on the back-end of my
How to convert this JavaScript code to C++
Problem is to return any one combination from given array that sums up to the target. i'm new to c++. how can i complete the function howsum()
What is a List ? [JavaScript interview question]
What exactly is a "list" in javascript? i got asked this question and i'm a professional of five years but this made me fumble. i
Ad
Key of highest occurring value in JavaScript map?
Given a javascript map of (key, value) pairs. find the 'key' of highest frequency 'value' ( say
Taking the alternate value from tuple
How to take the other(unmatched value) from tuple? for example: i have val = 'y' and t = ('y', 'n')
Fast way to create a unique string ID/key from a known set of potential IDs in JavaScript
Say you want to have a set of 1- to 2-digit hexadecimal numbers, so 256 numbers. just using a small set to get at the problem, but it would work
Python combine two lists of dictionaries of unequal lengths into a single list based on a key
I am using cassandra with python and i am executing two queries together. i want to group the results of the results together into a single list
Splitting a number and creating new individual columns for each number split using Pandas
Good day, i have a data frame with a column like this, let us assume with 1000rows but here is a sample: a 12 24 36 48
Show all the posts of the pages that the user follow
I want to present all the posts ,of the pages, which the user follow. i have table "followings" with the fields "user_id" and "page_id"( for
How to display list data in tree structure in Java?
I have an arraylist and i want to display in a hierarchal structure. i want the results to look like this. if it doesn't have any child
My function is returning segmentation fault error for aparently nothing wrong
I'm making an hashing table data structure and having segmentation fault error on my inicialization function. here the code: void
How do I remove a specific leaf node with index value X and display the remaining leaf nodes?
Test case: input: 5 -1 0 0 1 1 2
How to print the elements of a struct?
I have made this program to save the information about a book but it doesn't print it correctly #include <stdio.h> enum
data structure for file path string find insert delete
I monitor the filesystem event, and store event using path as key, when multiple event of a path occures i need find a the previous event and
Ad
Redux + Reselect: Preventing selector recalculation when GPS data updates
Recently, i've been working on a very large application using react+redux with reselect to memoize data and prevent unnecessary re-renders, and
find the kth smallest number in java
Below is the java code to find the kth smallest number in array. this code is for elementary version, not using pivot-index.
Ad
Blog Categories
Ad