All Questions
8,064
questions
-1
votes
0
answers
22
views
What should I focus while learning DSA? [closed]
So basically I am learning DSA for the first time and I dont want to overlearn or learn things that aren't neccessary. Can anyone tell me what I should focus on?
DSA learning I am learning quick union ...
0
votes
1
answer
62
views
How to store row-position in a database?
I am looking to emulate a feature in Excel/Google Sheets where there is a table of data, but someone may move a row up or down. Here is an example of the interaction:
My first thought as to how to ...
-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 ...
1
vote
3
answers
113
views
In-Place Reordering of Doubly Linked List Nodes to Ensure Memory Contiguity
I am working on a program that deals with doubly linked lists that are allocated within a bounded memory region:
constexpr std::size_t numNodes = 15;
Node* block = new Node[numNodes];
I would like to ...
2
votes
2
answers
82
views
Finding the subarray with the least median given a size K and an array of length N
I have been struggling the past month with this problem that was given to us on our course while I was upsolving it. The task is to find the window of size K with the least median in an array of ...
1
vote
2
answers
79
views
How to sort an array by only being able to swap an element with another element two positions ahead (i+2)?
I have an array of integers that I need to sort. However, the only operation allowed is to swap an element at index i with the element at index i+2. This means traditional sorting algorithms like ...
1
vote
2
answers
94
views
Viable to sort IEEE754 floats by MSB?
I've been doing some low-level bit manipulation, and ended up creating an algorithm that sorts 64-bit floats by octets of descending significance (LE = 7 -> 0; BE = 0 -> 7) as a byproduct. When ...
-1
votes
2
answers
130
views
Time complexity of Insertion Sort Algorithm, if Array has 'I' number of inversions
I have recently been asked this question and was a little confused as I don't have a good grip on Sorting algorithms.
An array A contains 'I' number of inversions then what is the time
complexity of ...
-1
votes
1
answer
34
views
Why I receive an unknown variable error in my function?
I'm using AlgoBuild and inside the "input_vet()" function there's a while loop and in its condition I recall the variable N, which I assign a value in the main, and shows a unknown variable ...
0
votes
1
answer
50
views
Sorting with AlgoBuild. Why do I get an index is out of range error?
I am using AlgoBuild to make a program that sorts numbers.
This is my attempt:
AlgoBuild translates this chart to the following pseudo code:
PROGRAM main
INPUT int D
FOR i = 0; i < D; i = ...
2
votes
0
answers
72
views
Deterministically create a collection with 100 elements for worst case of Shell Sort algorithm
Two questions.
Can I deterministically generate an array with 100 elements (1,2,...,100) that is the worst case for the shell sort algorithm?
If no, why? Why is there only stochastic way?
What I ...
3
votes
4
answers
134
views
sorting algorithm in O(n) according a specific condition
Given an array A with n−1 numbers where n = 2^k
for some integer k. One of the values appears exactly n/2
another appears exactly n/4, and so on. More formally, for all 1 ≤ k ≤ log n exists a value ...
0
votes
2
answers
43
views
Worst running time cases for merging two sorted arrays of size n and m
I was doing a problem and I am getting a bit confused on the worst cases for using merge sort on two arrays of lengths n and m. The question already says that they are sorted and I am assuming they ...
2
votes
1
answer
73
views
Adjacent items in Quicksort's output: Does the algorithm guarantee they have been directly compared?
Is the direct comparison of adjacent items in the output array guaranteed by the Quicksort algorithm ?
In other words:
During the course of the sorting, the Quicksort algorithm makes (k-2)2^k+2 ...