Questions tagged [swap]

Changing position of two items.

Act of rearranging the locations of two items such that the first item now occupies the place of the second and the second item now occupies the place of the first.

2503 questions
0
votes
1 answer

vector going out of bounds depending on a swap statement

For this piece of code- vector v{ 417, 929, 845, 462, 675, 175, 73, 867, 14, 201, 777, 407, 80, 882, 785, 563, 209, 261, 776, 362, 730, 74, 649, 465, 353, 801, 503, 154, 998, 286, 520, 692, 68, 805, 835, 210, 819, 341, 564, 215, 984, 643, 381,…
anonymous38653
  • 393
  • 4
  • 16
0
votes
1 answer

What is the time complexity of the following piece of code

int FindSum(int[] A, int[] B){ int[] temp = A; A = B; B = temp; } here in this java code we are swapping both the arrays, in this case only the memory reference of arrays is changing or there is swapping of elements between A and…
0
votes
0 answers

Swapping fragments of matrices Matlab

I wrote a program implementing Gaussian Elimination with Complete Pivoting: function x = gecp(A,b) x = b; n = length(A); p = 1:n; l = b; for k = 1:n [i,j] = find(A(k:n,k:n)==max(abs(A(k:n,k:n)),[],'all')); i = i+k-1; j =…
MartinYakuza
  • 60
  • 1
  • 12
0
votes
1 answer

Regex to swap two texts using regex in VIM

Not a regex expert. But, after a bit of search online, I came up with this expression to swap two texts in my file: %s/(\s*\(&\)\(.*\), \(.*\)\s*);/( \3, \2 );/gc My initial text: read( ®Val.mAllBits, getAddr()+offset ); And I want to swap it…
singleX
  • 375
  • 4
  • 13
0
votes
1 answer

QuantLib: par swap rate calculation

I would like to calculate the par swap rates (i.e., the fixed leg rates), for swaps traded at par (i.e. market value = 0), given a zero-coupon curve with observed maturities ranging from 3 months to 120 months. Here's what I did: # define…
Jessica F.
  • 13
  • 1
  • 5
0
votes
0 answers

What would be the correct way to swap two specific members of an array?

I apologize if the question is very noobish, I have been only learning for 3 weeks. It's kind of overwhelming, even if you do simple things like I do. So I'm trying to create a program that manages "accounts" as practice and puts the users and the…
antl bvc
  • 1
  • 1
0
votes
3 answers

How do I swap a letter with its immediate neighbor in a string?

I am trying to create a function that takes a string as an argument and returns a list of all of the generated words by swapping a letter with its immediate neighbor. I first take each letter and create a list of strings and each string contains…
user7619593
0
votes
0 answers

Sort by row one, row two & row three in an ascending order using np.array list with an 2 Dimensional Array in python

I need to sort it by first row 1, row 2 & row 3 in ascending order using np.array list *Input* [[9, 3, 2], [4, 0, 1], [5, 8, 6]] *Expected output* [[4 0 1] [5 8 6] [9 3 2]] Using the below logics gets partially correct array_test =…
user13526138
  • 41
  • 2
  • 7
0
votes
0 answers

How to copy files from production to staging slot before swapping in azure piplines

We have a website that has an upload functionality for the CMS. When we do a release, the Azure pipeline we configured, deploys that release to the staging slot and then swaps staging and production. However any uploaded files are now on staging and…
PeterB
  • 43
  • 6
0
votes
0 answers

Are python function arguments passed by reference?

From Python's documentation, I could not understand if arguments are passed by reference or passed by assignment. So, I wrote a simple piece of code to verify it. def swap(first_number, second_number): first_number, second_number =…
Pikachu
  • 304
  • 3
  • 14
0
votes
2 answers

PSET4 CS50 Reflect Assignment; Code is failing the tests

I can't find a way to fix these two errors despite my pic turns out fine. Would appreciate it if anyone can enlighten me. This is the report I get: :( reflect correctly filters 1x2 image expected "0 0 255\n255 0...", not "255 0 0\n0 0 2..." …
Pei Xuan
  • 3
  • 2
0
votes
3 answers

Reverse output from array isnt working as expected

So I got a little question again about array swapping. So I got this little piece of code here: public static void main(String[] args) { Scanner scan = new Scanner(System.in); Random random = new Random(); int indexe = scan.nextInt(); …
Marius1773
  • 23
  • 5
0
votes
1 answer

Linux Process details with Swap and Memory Usae

I am checking swap for sqpctl process by using this script: for file in /proc/*/status ; do awk '/VmSwap|Name|Pid/{printf $2 " " $3}END{ print ""}' $file; done | sort -k 5 -n -r | grep sqpctl How to get the output of the above with proper process…
arsm4
  • 101
  • 2
  • 10
0
votes
0 answers

Is there any way to swap memory in php?

I'm trying to figure out how to decrease the memory usage in a php script. Problem is that I need to use ini_set('memory_limit','1024M'); because I load 2 big arrays (2Million entries each) and I was wondering if I could swap memory in any…
Nacho
  • 1
0
votes
2 answers

Looking for jQuery script to swap div contents depending on checkbox checked/unchecked

I'm looking for a quick script to change a div when a checkbox is checked. For example: Check the checkbox and "div1" appears. Uncheck the checkbox and "div2" appears. Visual example: http://www.mmo-champion.com/ Take a look at there "Recent Forum…
Bryan
  • 1
  • 1
1 2 3
99
100