Posts

Best and worst case running time of an algorithm -

i need calculate best , worst case running time of following algorithm. matter need consider i*i in second loop? , complexity of loop q(n^2) ? i=1 2*n j=1 i*i k=1 k<j if j%i==0 sum=sum+1; this full code procedure proc(n:integer){ var i,j,k :integer var sum: integer begin sum=0; i=1 2*n begin j=1 i*i begin k=1 k<j begin if j%i==0 sum=sum+1; end if k=k+1; end j=j+1; end i=i+i; end end } let's analyze inside out. if j%i==0 sum=sum+1; this takes constant time every time reached. k=1 k<j the inner loop runs o(j) times, once each value of k 1 j (exclusive). far have o(j*1) = o(j) j=1 i*i for middle loop - each value of j has job in complexity of o(j) . means, going need entire loop (for each value of i...

commit - How to get (only) author name or email in git given SHA1? -

i check author's e-mail , name, surname verify who's pushing repo. is there way can come command in git show commiter's name/e-mail given sha1 of commit? this came it's far ideal solution (the first solution git hook that's why it's using 2 sha1s rev-list . second 1 uses git show ): git rev-list -n 1 --pretty=short ccd3970..6ddf170 | grep author | cut -d ' ' -f2- | rev | cut -d ' ' -f2- | rev git show 6ddf170 | grep author | cut -d ' ' -f2- | rev | cut -d ' ' -f2- | rev you can use following command: git log --format='%ae' hash^! it suppose work git show well, reason doesn't me when tried it. git show --format='%ae' hash

android - Dismiss non-application Window when Home button pressed -

i have non-application window (i.e. window no activity context, appears on other apps). window technically view has been added using windowmanager.addview() , type_system_error . i remove window when home button pressed seems impossible intercept home button press. is there way this? edit: app not have activity cannot use methods on activity class. you can detect when user press home button with: http://developer.android.com/reference/android/app/activity.html#onuserleavehint() but can't override system behaviour action.

Responsive Telerik RadHtmlChart -

i using telerik radhtml chart need chart should auto size based on screen resolution how it. have tried set width , height auto not working. chart containing in datalist code block below <asp:updatepanel id="pnlcontainer" runat="server" updatemode="conditional"> <contenttemplate> <div id="wrapper"> <asp:datalist id="dtlstdashboards" runat="server" repeatcolumns="2" repeatdirection="horizontal" onitemdatabound="dtlstdashboards_itemdatabound" width="100%" datakeyfield="dashboardid"> <itemtemplate> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td align="left...

java - Behavior of entrySet().removeIf in ConcurrentHashMap -

i use concurrenthashmap let 1 thread delete items map periodically , other threads put , items map @ same time. i'm using map.entryset().removeif(lambda) in removing thread. i'm wondering assumptions can make behavior. can see removeif method uses iterator go through elements in map, check given condition , remove them if needed using iterator.remove() . documentation gives info concurrenthashmap iterators behavior: similarly, iterators, spliterators , enumerations return elements reflecting state of hash table @ point @ or since creation of iterator/enumeration. hey not throw concurrentmodificationexception. however, iterators designed used 1 thread @ time. as whole removeif call happens in 1 thread can sure iterator not used more 1 thread @ time. still i'm wondering if course of events described below possible: map contains mapping: 'a'->0 deleting thread starts executing map.entryset().removeif(entry->entry.getvalue()==0) delet...

javascript - React / JSX Dynamic Component Name -

i trying dynamically render components based on type. for example: var type = "example"; var componentname = type + "component"; return <componentname />; // returns <examplecomponent /> instead of <examplecomponent /> i tried solution proposed here react/jsx dynamic component names that gave me error when compiling (using browserify gulp). expected xml using array syntax. i solve creating method every component: newexamplecomponent() { return <examplecomponent />; } newcomponent(type) { return this["new" + type + "component"](); } but mean new method every component create. there must more elegant solution problem. i open suggestions. <mycomponent /> compiles react.createelement(mycomponent, {}) , expects string (html tag) or function (reactclass) first parameter. you store component class in variable name starts uppercase letter. see html tags vs react components . var m...

java - How to set Adapter for listview with image in Android -

i have click button show listview image. unfortunately, application stops when click on button. have set custom adapter still same. here code: public class r1 extends activity { string[] signtitle; string[] signdescription; int images[]={r.drawable.a,r.drawable.b,r.drawable.c,r.drawable.d,r.drawable.e,r.drawable. f,r.drawable.g,r.drawable.h}; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.r1); resources res = getresources(); signtitle = res.getstringarray(r.array.titile); signdescription = res.getstringarray(r.array.description); listview lv = (listview) findviewbyid(r.id.listview); customlistadapter adapter = new customlistadapter(this,signtitle,images,signdescription); lv.setadapter(adapter);} customadpater.java public class customlistadapter extends arrayadapter<string> { context c...