Questions tagged [data-structures]
A data structure is a way of organizing data in a fashion that allows particular properties of that data to be queried and/or updated efficiently.
data-structures
34,014
questions
0
votes
0
answers
4
views
Unable to process the type of data structure returned by Supabase database
I am using Edge Functions written in Typescript fetch data from my table in Supabase database. Unable to understand how I am supposed to process the returned request. Coding in VS Code, I have no idea ...
-4
votes
1
answer
39
views
Why is swapping using function and swapping using assignment produce in different results?
This is the code for Quick sort in which i used assignment to swap the values.
def partion(arr,low,high):
partion_index=low
pivot=arr[partion_index]
while (low < high):
while low < ...
0
votes
1
answer
40
views
Kotlin data structure for efficient lookup of nested data
I am currently working on an application that needs to create a mapping between document pdfs and corresponding JSON data files. The files are coming from a third party so I have no control over their ...
0
votes
2
answers
55
views
How is my algorithm for stock span problem incorrect?
The question :
The stock span problem is a financial problem where we have a series of n daily price quotes for a stock and we need to calculate the span of stocks price for all n days.
The span Si of ...
0
votes
0
answers
21
views
Question About Node Replacement Strategy in Linux Red-Black Tree: Why Not Simply Swap Data Instead of Nodes?
I'm looking at the node replacement method in the Linux Red-Black tree implementation (rb_replace_node). To replace the victim node with newnode, all pointers that were pointing to victim are ...
-1
votes
1
answer
72
views
Shuffle the Array - LeetCode problem. 2 pointers approach fails [closed]
I am trying to solve LeetCode problem 1470. Shuffle the Array:
Given the array nums consisting of 2n elements in the form [x1,x2,...,xn,y1,y2,...,yn].
Return the array in the form [x1,y1,x2,y2,...,xn,...
0
votes
1
answer
53
views
Understanding Time complexity of nested sorting
I am solving this LeetCode problem 1636. Sort Array by Increasing Frequency:
Given an array of integers nums, sort the array in increasing order based on the frequency of the values. If multiple ...
0
votes
3
answers
55
views
Time complexity analysis of data structures
I got a bit confused about analzsis of data structure basic operation like inserting or deleting.
when I am asked about creating an data structure that support deleting operation, or inserting in O(1),...
-2
votes
1
answer
44
views
Given a number N find the number just smaller than N such that it has a given digit x present in it x times [closed]
You will receive an input number N in string format and also a number x. Your task is to find the largest number that is smaller than N and contains the digit x exactly x times.
For example: N = ...
-1
votes
0
answers
29
views
Java add method is not working during arraylist iteration [duplicate]
Add method is not working in Iteration of arraylist but remove method is working in iteration of arraylist.
package thread;
import java.util.ArrayList;
import java.util.Iterator;
import java.util....
0
votes
1
answer
34
views
Performance Comparison Between Tabulation and Memoization for Dynamic Programming [closed]
I'm delving into dynamic programming and trying to understand the general performance differences between tabulation and memoization. Both techniques aim to optimize recursive algorithms by storing ...
1
vote
2
answers
68
views
Reading and grouping files from a directory in Zig
I have a folder of images that contains several thousand images in 3 different formats: png, jpg and webp. For instance: boat.png, boat.webp, plane.jpg, plane.png, plane.webp.
I decided to learn Zig ...
1
vote
2
answers
47
views
Implementing a Stack in Python: Problem with the POP function
I'm trying to implement the Stack Data Structure in Python from scratch. Unfortunately, I have a problem with the pop functionality.
The pop function should delete the top element of the stack. ...
0
votes
1
answer
47
views
Efficient data structure for matching items in two lists of data -python
I have two lists where one list is filled with ID's and the other list is filled with process names. Multiple process names can share an ID.
I want to be able to create a data structure where I can ...
-1
votes
1
answer
54
views
The best data-model to store nested tags? [duplicate]
I'm trying to make a breadcrumb for a ecommerce website. Something like this:
Home > Kitchen > Serving and reception > Spoon
Each of those item are a tag. So, the tags table is parent-based/...