Category "data-structures"

heapify VS build heap

Can you please confirm the meaning of the concept 'heapify', the source I am learning from says that heapify is building a heap from an array (from scratch) Thi

Find the max value of the same length nails after hammered

I'm trying to solve this problem: Given an array of positive integers, and an integer Y, you are allowed to replace at most Y array-elements with lesser val

Transform the following infix expression to postfix form (using stacks)

guys please its due asapp Transform the following infix expression to postfix form (using stacks). (A + 2) * (B - C + D * E) + F

Get simplified dictionary from a dict of dicts with Ansible

I have the following data structure: site_subnets: control: { network: "100.99.97.0/24", mtu: "1500", vm_start_offset: 0, dhcp_from_ip: "30", dhcp_to_ip: "5

Show total number of selected filters array of items in React

I have the following problem. In widgetFilters array (length===3) i want to show the numbers of selected items in the header of the Filter. const [selectedFil

how to convert binary heap sort to d_ary heap sort?

Hi I have an algorithm that uses binary tree to heapify and then sort the list i need to convert this sort algorithm to change into d-heap or d-ary heap or k-ar

Why do we need stacks when we already have so many data structures

Why do we need stacks when we already have so many data structures that can also handle managing data in reverse directions [linked list & vectors]? What's

Diagonal difference of a nested List C#

I'm trying to get from a function the absolute difference of a nested list. I have a fixed matrix, and I would like to get the result when is not fixed. At the

converting each element from string to int in nested list in python [duplicate]

I have data in python with nested lists, a part of which looks like: data = [['214', '205', '0', '14', '710', '1813494849', '0'], ['214', '204

I started learning DSA ,while writing code for stack DS in c++ , I came across this error

I started learning DSA ,while writing code for stack DS in c++ , I came across this error. So, while I was trying fixing it , I get to know that when I am using

What's the point of the colors in red/black trees?

We know AVL trees are better for searching and red-black trees are better for insertion and deletion because they require lesser rotations, but what is the need

Fastest way to read a CSV file java

I´ve been trying to read several csv files (arround 20 MB) using openCSV, but so far it has been slow. Im trying to read 4 csv files which I´m loadi

Reasons for using a Bag in Java

I am currently studying about Algorithms & Data Structures and while I was reading over the Book of Algorithms 4th edition, I discovered the Bag data-struct

Understanding the Big O for squaring elements in an array

I was working on a problem where you have to square the numbers in a sorted array on leetcode. Here is the original problem Given an array of integers A sor

Random access of a linked list element

In an article about linked list, it is said that accessing a random element is not allowed and to access a certain node we need to traverse it from the head nod

How to approach this Dynamic Programming Meal Plan Problem?

I came across this problem in a practice interview. I don't want a direct answer, just some help with the intuition of the problem, both your brute force thinki

How to generate the worst case for disjoint set with only path compression?

A disjoint set with only path compression implemented is like this: // In cpp. int Find(int x) { return f[x] == x ? x : f[x] = Find(f[x]); } int Union(int a, i

Amazon interview: Min stack

I recently had my Amazon interview for SDE. I was asked to design a stack which does push, pop and min in O(1). I got the logic and implemented the push of the

An undirected graph having n edges, then find out no. of vertices that graph have?

An undirected graph having 'n' number of edges, then find out number of vertices that graph have?‏‏‎

Finding the shortest path with only passing specific edge less or equal to one time in Graph

Given a undirected graph that it has ordinary edges and specific edges, our goal is to find the sum of the shortest path's weight between two vertices(start ve