Total Pageviews

Featured Post

Excel tips and tricks

Things to Remember Borders can be used with the shortcut key Alt + H + B, which will directly take us to the Border option. Giving a border...

Sunday, August 5, 2012

programs

ABC, ACB, BAC, BCA, CAB, CBA.using System;

namespace ConsoleApplication3
{
class Permute
{
private void swap (ref char a, ref char b)
{
if(a==b)return;
a^=b;
b^=a;
a^=b;
}

public void setper(char[] list)
{
int x=list.Length-1;
go(list,0,x);
}

private void go (char[] list, int k, int m)
{
int i;
if (k == m)
{
Console.Write (list);
Console.WriteLine (" ");
}
else
for (i = k; i <= m; i++)
{
swap (ref list[k],ref list[i]);
go (list, k+1, m);
swap (ref list[k],ref list[i]);
}
}
}

class Class1
{
static void Main()
{

Permute p = new Permute();
string c="sagiv";
char []c2=c.ToCharArray ();
/*calling the permute*/
p.setper(c2);
}
}
}You can find above program and algorithm onhttp://efreedom.com/Question/1-756055/Listing-Permutations-String-Integer



binary searc recusion.


using System;


public class BinarySearch {
public static int Search (int[] data, int key, int left, int right) {
if (left <= right) { int middle = (left + right)/2; if (key == data[middle]) return middle; else if (key < data[middle]) return Search(data,key,left,middle-1); else return Search(data,key,middle+1,right); } return -1; } public static void Main(String[] args) { int key; // the search key int index; // the index returned int[] data = new int[10]; for(int i = 0; i < data.Length; i++) data[i] = i; key = 9; index = Search(data, key, 0, data.Length-1); if (index == -1) Console.WriteLine("Key {0} not found", key); else Console.WriteLine ("Key {0} found at index {1}", key, index); } } http://w3mentor.com/learn/asp-dot-net-c-sharp/c-collections-and-generics/examples/recursive-implementation-of-binary-search-in-csharp/ binary serach iteration; http://www.philosophicalgeek.com/category/microsoft/live-search-microsoft/ http://w3mentor.com/learn/category/asp-dot-net-c-sharp/ ================================= Largest sum subarray June 14, 20126 Comments Recursion: M[i] = max sum subarray ending here M[i] = max(M[i-1] + a[i], a[i]) Loved this code #include

#include

using namespace std;

int main() {


int n;

cin >> n;


int max_sum = 0, run_sum = 0;


for (int i = 0, t = -1; i < n; ++i) { cin >> t;


run_sum = max(run_sum + t, t);


max_sum = max(run_sum, max_sum);


}

cout << max_sum << endl;

return 0;


}


-================

Two tier 3 tier testing FAQs

Difference between two tier testing and three tier testig?


http://softwaretestingguide.blogspot.com/2009/09/what-is-difference-between-two-tier.html
Abstractoverride

http://blogs.msdn.com/b/jmstall/archive/2005/08/07/abstract-override.aspx


http://social.msdn.microsoft.com/Profile/mike%20stall%20-%20msft/activity

.8.1 Fully qualified names
Visual Studio .NET 2003
Every namespace and type has a fully qualified name, which uniquely identifies the namespace or type amongst all others. The fully qualified name of a namespace or type N is determined as follows:
• If N is a member of the global namespace, its fully qualified name is N.
• Otherwise, its fully qualified name is S.N, where S is the fully qualified name of the namespace or type in which N is declared.
In other words, the fully qualified name of N is the complete hierarchical path of identifiers that lead to N, starting from the global namespace. Because every member of a namespace or type must have a unique name, it follows that the fully qualified name of a namespace or type is always unique.
The example below shows several namespace and type declarations along with their associated fully qualified names.
Copy
class A {} // A
namespace X // X
{
class B // X.B
{
class C {} // X.B.C
}
namespace Y // X.Y
{
class D {} // X.Y.D
}
}
namespace X.Y // X.Y
{
class E {} // X.Y.E
}

Pasted from


================================
Message disposal

My service operation has an untyped contract and I'm trying to save the messages that it receives for processing later. However, the messages always say that they are closed before I can read them. Why are the messages closed?
Messages are good for a single use, which means that once someone has finished with the message, no one else can read it even if there are multiple references pointing to the same message object. Most commonly, the service is responsible for reading and closing the messages. If you have a typed contract, then the service has to read the message to produce the types. If you have an untyped contract though, the service can hand the message to you without having read it. In either case, the service takes responsibility for closing the message after the service operation completes. This prevents you from having to think about the messages and clean up after them.
When you intend to process a message later, it's clearly not a good thing for the service to think that it is responsible for closing the message after the service operation completes. You can tell the service that you want to take control of cleaning up messages so that the service does not have this responsibility. To mark service operations for manual cleanup, add an OperationBehavior attribute to the service operation implementation that sets AutoDisposeParameters to false. It is now entirely your responsibility to clean up messages after processing is complete.

Pasted from


=====================
late binding
http://support.microsoft.com/kb/245115
======================
http://blogginman.blogspot.com/2008/08/amazon-interview.html




few FAQ

1)virtual vs abstract-

Virtual-may overiden
Abstract-must overriden has to be

An abstract function has to be overridden while a virtual function may be overridden. – Jordan Parmer Dec 24 '08 at 14:14

Pasted from

An abstract function can have no functionality. You're basically saying, any child class MUST give their own version of this method, however it's too general to even try to implement in the parent class. A virtual function, is basically saying look, here's the functionality that may or may not be good enough for the child class. So if it is good enough, use this method, if not, then override me, and provide your own functionality

Pasted from

An abstract function has no implemention and it can only be declared on an abstract class. This forces the derived class to provide an implementation. A virtual function provides a default implementation and it can exist on either an abstract class or a non-abstract class.

Pasted from



http://www.compiledthoughts.com/2008/03/abstract-vs-virtual-explained.html

2)constant readonly-


The difference is that the value of a static readonly field is set at run time, and can thus be modified by the containing class, whereas the value of a const field is set to a compile time constant.
In the static readonly case, the containing class is allowed to modify it only
• in the variable declaration (through a variable initializer)
• in the static constructor (instance constructors, if it's not static)
static readonly is typically used if the type of the field is not allowed in a const declaration, or when the value is not known at compile time.
Instance readonly fields are also allowed.
Remember that for reference types, in both cases (static and instance) the readonly modifier only prevents you from assigning a new reference to the field. It specifically does not make immutable the object pointed to by the reference.
class Program
{
public static readonly Test test = new Test();
static void Main(string[] args)
{
test.Name = "Program";
test = new Test(); // Error: A static readonly field cannot be assigned to (except in a static constructor or a variable initializer)
}
}
class Test
{
public string Name;
}
On the other hand, if Test were a value type, then assignment to test.Name would be an error.

Pasted from


polymorphism

Polymorphism is defined as one interface to control access to a general class of actions. There are two types of polymorphism one is compile time polymorphism and the other is run time polymorphism. Compile time polymorphism is functions and operators overloading. Runtime time polymorphism is done using inheritance and virtual functions.

Polymorphism means that functions assume different forms at different times. In case of compile time it is called function overloading. For example, a program can consist of two functions where one can perform integer addition and other can perform addition of floating point numbers but the name of the functions can be same such as add. The function add() is said to be overloaded. Two or more functions can have same name but their parameter list should be different either in terms of parameters or their data types. The functions which differ only in their return types cannot be overloaded. The compiler will select the right function depending on the type of parameters passed. In cases of classes constructors could be overloaded as there can be both initialized and uninitialized objects. Here is a program which illustrates the working of compile time function overloading and constructor overloading.

Read more: http://wiki.answers.com/Q/Difference_between_runtime_and_compile_time_polymorphism#ixzz22EIdLFWo

Pasted from



Where we use new keyword other than instantiation ?

Default constructor int i=new int()

New and oveerride cannot used at a time..

What's the difference between override and new?

CSharpFAQ

This is all to do with polymorphism. When a virtual method is called on a reference, the actual type of the object that the reference refers to is used to decide which method implementation to use. When a method of a base class is overridden in a derived class, the version in the derived class is used, even if the calling code didn't "know" that the object was an instance of the derived class. For instance:
public class Base
{
public virtual void SomeMethod()
{
}
}
public class Derived : Base
{
public override void SomeMethod()
{
}
}
...
Base b = new Derived();
b.SomeMethod();
will end up calling Derived.SomeMethod if that overrides Base.SomeMethod. Now, if you use the new keyword instead of override, the method in the derived class doesn't override the method in the base class, it merely hides it. In that case, code like this:
public class Base
{
public virtual void SomeOtherMethod()
{
}
}
public class Derived : Base
{
public new void SomeOtherMethod()
{
}
}
...
Base b = new Derived();
Derived d = new Derived();
b.SomeOtherMethod();
d.SomeOtherMethod();
Will first call Base.SomeOtherMethod (line 3), then Derived.SomeOtherMethod (line 4). They're effectively two entirely separate methods which happen to have the same name, rather than the derived method overriding the base method.
If you don't specify either new or overrides, the resulting output is the same as if you specified new, but you'll also get a compiler warning (as you may not be aware that you're hiding a method in the base class method, or indeed you may have wanted to override it, and merely forgot to include the keyword).
That provides the basics of overriding and the difference between new and override, but you should really see a book or tutorial for a more in-depth look at polymorphism.

Pasted from


How to decide wch one to use Message contarct data contarct ?


There are actually three choices to consider for describing the messages that your service uses: data contracts, message contracts, and XML serialization. You will be forced to use XML serialization in some cases because you have an existing message format with precise specification of XML elements and attributes that you need to replicate. In these cases, it may simply be impossible to duplicate this exact XML schema with a message or data contract-based description, forcing you to use XML serialization to describe the messages.
However, let's assume that the existing message format is not so unreasonable and you have a choice between the various options for describing messages with contracts. How do you choose between data contracts and message contracts? The choice may not always seem clear if both types of contracts are capable of describing your messages. A rule of thumb though is that data contracts are generally portable between different kinds of XML encodings, making this option preferable if you might choose to project the Infoset differently in the future. Message contracts are more limited in the projections that they can support but are reasonably adept at mimicking the most common types of XML messages produced today.
Therefore, there is a preference to use data contract, followed by message contract and XML serialization. However, the ability to adapt to a preset form is ranked in the reverse order. When you're required to conform to an existing message layout, you are more likely to be forced to use message contracts. When you are designing new message layouts, you almost always want to use data contracts.

Pasted from


List of simple programs


 
Arrays:
1. Merge two sorted arrays.
2. Given set of integers and an integer N, write program to check whether there exists integers A and B in array such that A+B =n.
(use brute force).
  3. K th largest element in an array.
4.Largest sum of subarray

Strings:
 
1. First Non repeated char in a string
2. Reverse words
3. Remove char in a string
4. replace sub string.
5. Find sub string
6. Find occurrences of sub string in a string
7. Longest Palindrome in a string
8. Anagrams
 
Linked list:
  reverse slll(basis program)
 
1. Find nth node from the end is good to practice
 
SLL
DLL
CLL
 
Stacks:
1. Implement stack using array/ linked list/queue/array list
Queues:
1. Implement a queue of integers of user-specified size using a simple array. Provide routines to initialize(), enqueue() and dequeue() the queue. Make it thread safe.
2. Priority Queue
Tress:
1. Binary tree
2. DFS
3. BFS
 
 
Sorting:
 
1. Quick sort
2. Merge sort
 
 
Recursion problems:
 
1. Reverse string
2. Binary search
3. Fibonacci
4. factorial
 
 
Search:
 
1. Binary search (easy no need effort)
 
 
Date and Time Problems:
1. Find date on a given day.
 
Clock problem:
2. Angle between two needles
 
Triangle problem:
 
 
1. Write me a function that receives three integer inputs for the lengths of the sides of a triangle and returns one of four values to determine the triangle type (1=scalene, 2=isosceles, 3=equilateral, 4=error). Generate test cases for the function assuming another developer coded the function
 
 
 
Game:
 
1. Tic tac toe //if you have time and preparing for FTE do this.
 
 
Need some effort on .
SQL:
Testing:
ASP.net
ADO.NET
Web testing:
Scripting:
Networking
Debugging
====================