[algogeeks] fastest sequential access

2012-11-21 Thread shady
which data structure among the follow has fastest sequential access ? i) vector ii) Singly linked list iii) Doubly linked list it won't be doubly linked list as it involves more pointer manipulations than singly linked list... --

Re: [algogeeks] Re: Largest contigious subarray with average greather than k

2012-11-21 Thread Sachin Chitale
Hello, Algorithm-- 1. Find out start and end index of contiguous subarray which has max sum O(n) 2.Once u have start and end index calculate avg if it satisfies the condition then done O(n) 2.1 other wise run a loop through start to end index and remove trailing elements by increasing start

[algogeeks] Array problem

2012-11-21 Thread Ansum Baid
This question has been taken from codeforces.com. Any idea how to solve this ? Polycarpus has an array, consisting of *n* integers *a*1, *a*2, ..., *a**n*. Polycarpus likes it when numbers in an array match. That's why he wants the array to have as many equal numbers as possible. For that

Re: [algogeeks] Re: Largest contigious subarray with average greather than k

2012-11-21 Thread Sachin Chitale
Implementation public class Kadanes { static int maxAvgSum(int a[], float k) { int max_so_far = 0, max_ending_here = 0, avg = 0, s = -1, e = -1, ts, te, tsum; boolean flag = false; for (int i = 0; i a.length; i++) { if (max_ending_here == 0) s = e = i; max_ending_here = max_ending_here +

[algogeeks] Game

2012-11-21 Thread Wladimir Tavares
Arnaldo and Bernaldo are playing within the classroom as follows: they write initially under a positive integer n. then alternately, beginning with Arnold, erase the number that is on the table and write a new number that can be: • what has just been erased least the largest power of 2 (with

Re: [algogeeks] fastest sequential access

2012-11-21 Thread vishal chaudhary
singly linked list On Wed, Nov 21, 2012 at 8:21 PM, shady sinv...@gmail.com wrote: which data structure among the follow has fastest sequential access ? i) vector ii) Singly linked list iii) Doubly linked list it won't be doubly linked list as it involves more pointer manipulations

Re: [algogeeks] Array problem

2012-11-21 Thread Dave
@Ansum: Polycarpus should start by summing the numbers. If the sum is divisible by n, then n numbers can be made equal. If the sum is not divisible by n, then only n-1 numbers can be made equal. Dave On Wednesday, November 21, 2012 12:18:54 PM UTC-6, Ansum Baid wrote: This question has

Re: [algogeeks] Array problem

2012-11-21 Thread Ansum Baid
@Dave: Can you give a little insight on your approach? On Wed, Nov 21, 2012 at 6:52 PM, Dave dave_and_da...@juno.com wrote: @Ansum: Polycarpus should start by summing the numbers. If the sum is divisible by n, then n numbers can be made equal. If the sum is not divisible by n, then only n-1

Re: [algogeeks] fastest sequential access

2012-11-21 Thread atul anand
@shady : as subject says fastest sequential access , then if i am not getting it wrong.we only care of sequential access a value not modifying the linked list. so i guess double linked list would be helpful 1) bcozz it can move in both the direction , so if linked list is sorted then it would be