top button
Print Preview

I am confused what this question is telling and I also like to know the complete solution of this question.

0 votes
69 views

1) Write a program that computes
4\cdot \sum_{k=1}^{10^6} \frac{(-1)^{k+1}}{2k-1} = 4\cdot(1-1/3+1/5-1/7+1/9-1/11\ldots).

and
also how to do this by the method asked in the question;
2) Write a function that rotates a list by k elements. For example [1,2,3,4,5,6] rotated by two becomes [3,4,5,6,1,2]. Try solving this without creating a copy of the list. How many swap or move operations do you need?

these both questions are from https://adriann.github.io/programming_problems.html

posted Jan 6 by Harshil Pasnani

Share this question
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button

1 Answer

0 votes

First question where "4\cdot \sum_{k=1}^{10^6} \frac{(-1)^{k+1}}{2k-1} = 4\cdot(1-1/3+1/5-1/7+1/9-1/11\ldots)." is mentioned -- that seems like a rendering issue -- the formula is not printed properly.

In second question, you are supposed to "left shift" elements of list by given number. They provided example with 2. So, the initial list is: [1,2,3,4,5,6]; if you left shift by one position it would become [2, 3, 4, 5, 6] -- but they expect you to keep it "circular", so "1" has to go back at the end. So, it should become [2,3,4,5,6, 1]. That's one left shift (k = 1). If you do one more time, k would be 2 and resulting list will be [3,4,5,6,1,2].

Your program should be generic for any given value of k.

answer Jan 28 by Mehul Bhatt
Similar Questions
–1 vote

In Computer , Array and Stack both are used to store information in memory ..

so, What is the difference between Array and stack?

0 votes

Should we answer specific technical terms or software need or in general technology required or in general how would be the company's environment?
It would be good if answer is from freshers perspective, with specific examples. For eg. The Designation is for Graduate engineer trainee (software/hardware).

0 votes

Hey there,I'm from Bangalore and have completed my Engineering(CSE).I'm confused about what to do next. I had taken up PGCET (MBA) and have got a pretty good rank as well. According to the previous year cut-off rankings I might get a seat in PESIT or MSRIT. So,is it worth doing an MBA in HR as a Computer Science graduate or should i look for a job..?

...